This commit is contained in:
Todd Gruben 2018-06-18 14:08:22 -05:00
parent 07ab60d6cf
commit 18c67269ae

View file

@ -337,32 +337,18 @@ 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"]
var info *pilosa.IndexInfo
for _, idx := range h.API.Schema(r.Context()) {
if strings.Compare(idx.Name, indexName) == 0 {
info = idx
break
if idx.Name == indexName {
if err := json.NewEncoder(w).Encode(idx); err != nil {
h.Logger.Printf("write response error: %s", err)
}
return
}
}
if info == nil {
http.Error(w, fmt.Sprintf("Index %s Not Found", indexName), http.StatusNotFound)
return
}
if err := json.NewEncoder(w).Encode(info); err != nil {
h.Logger.Printf("write response error: %s", err)
}
http.Error(w, fmt.Sprintf("Index %s Not Found", indexName), http.StatusNotFound)
}
/*
type getIndexResponse struct {
Index map[string]string `json:"index"`
Fields map[string]string `json:"fields"`
}
*/
type postIndexRequest struct {
Options pilosa.IndexOptions `json:"options"`
}