コード例 #1
0
func (d *DashboardHTTPService) readBodyAsDashboard(id string, r *http.Request) (*schemas.Dashboard, error) {
	var dboard schemas.Dashboard
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return &dboard, err
	}
	err = json.Unmarshal(body, &dboard)
	if err != nil {
		return &dboard, err
	}
	dboard.Id = id
	return &dboard, nil
}
コード例 #2
0
func (e *ElasticsearchDatastore) Add(dboard schemas.Dashboard) error {
	if dboard.Version == 0 {
		dboard.Version = schemas.DASHBOARD_VERSION
	}

	e.logger.Trace.Printf("Adding dashboard: %s\n", dboard.Id)
	_, err := e.conn.Index(e.index, "dashboard", dboard.Id, nil, dboard)
	if err != nil {
		return err
	}

	return nil
}