Skip to content

Commit

Permalink
Merge pull request FeatureBaseDB#1388 from tgruben/issue-1283
Browse files Browse the repository at this point in the history
added fields meta to index http endpoint
  • Loading branch information
jaffee authored Jun 18, 2018
2 parents b4c7c40 + f412f4d commit 6ef9b0b
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,21 +352,15 @@ func (h *Handler) handleGetIndexes(w http.ResponseWriter, r *http.Request) {
// handleGetIndex handles GET /index/<indexname> requests.
func (h *Handler) handleGetIndex(w http.ResponseWriter, r *http.Request) {
indexName := mux.Vars(r)["index"]
index, err := h.API.Index(r.Context(), indexName)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}

if err := json.NewEncoder(w).Encode(getIndexResponse{
map[string]string{"name": index.Name()},
}); err != nil {
h.Logger.Printf("write response error: %s", err)
for _, idx := range h.API.Schema(r.Context()) {
if idx.Name == indexName {
if err := json.NewEncoder(w).Encode(idx); err != nil {
h.Logger.Printf("write response error: %s", err)
}
return
}
}
}

type getIndexResponse struct {
Index map[string]string `json:"index"`
http.Error(w, fmt.Sprintf("Index %s Not Found", indexName), http.StatusNotFound)
}

type postIndexRequest struct {
Expand Down

0 comments on commit 6ef9b0b

Please sign in to comment.