Merge pull request #313 from influxdata/feature/tr-wire-up-mappings
Wire up /mappings endpoint to layoutspull/316/head
commit
9a64acc898
|
@ -13,15 +13,25 @@ type mapping struct {
|
||||||
|
|
||||||
// GetMappings returns the known mappings of measurements to applications
|
// GetMappings returns the known mappings of measurements to applications
|
||||||
func (h *Service) GetMappings(w http.ResponseWriter, r *http.Request) {
|
func (h *Service) GetMappings(w http.ResponseWriter, r *http.Request) {
|
||||||
cpu := "cpu"
|
ctx := r.Context()
|
||||||
system := "System"
|
layouts, err := h.LayoutStore.All(ctx)
|
||||||
mp := getMappingsResponse{
|
if err != nil {
|
||||||
Mappings: []mapping{
|
Error(w, http.StatusInternalServerError, "Error loading layouts")
|
||||||
mapping{
|
|
||||||
Measurement: cpu,
|
|
||||||
Name: system,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mp := getMappingsResponse{
|
||||||
|
Mappings: []mapping{},
|
||||||
|
}
|
||||||
|
|
||||||
|
seen := make(map[string]bool)
|
||||||
|
|
||||||
|
for _, layout := range layouts {
|
||||||
|
if seen[layout.Measurement+layout.ID] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
mp.Mappings = append(mp.Mappings, mapping{layout.Measurement, layout.ID})
|
||||||
|
seen[layout.Measurement+layout.ID] = true
|
||||||
|
}
|
||||||
|
|
||||||
encodeJSON(w, http.StatusOK, mp, h.Logger)
|
encodeJSON(w, http.StatusOK, mp, h.Logger)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue