(w http.ResponseWriter, req *http.Request)
| 24 | } |
| 25 | |
| 26 | func (h *GetIndexHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { |
| 27 | // find the name of the index to create |
| 28 | var indexName string |
| 29 | if h.IndexNameLookup != nil { |
| 30 | indexName = h.IndexNameLookup(req) |
| 31 | } |
| 32 | if indexName == "" { |
| 33 | showError(w, req, "index name is required", 400) |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | index := IndexByName(indexName) |
| 38 | if index == nil { |
| 39 | showError(w, req, fmt.Sprintf("no such index '%s'", indexName), 404) |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | rv := struct { |
| 44 | Status string `json:"status"` |
| 45 | Name string `json:"name"` |
| 46 | Mapping mapping.IndexMapping `json:"mapping"` |
| 47 | }{ |
| 48 | Status: "ok", |
| 49 | Name: indexName, |
| 50 | Mapping: index.Mapping(), |
| 51 | } |
| 52 | mustEncode(w, rv) |
| 53 | } |
nothing calls this directly
no test coverage detected