( w http.ResponseWriter, req *http.Request)
| 40 | } |
| 41 | |
| 42 | func (h *AnalyzeDocHandler) ServeHTTP( |
| 43 | w http.ResponseWriter, req *http.Request) { |
| 44 | indexName := rest.IndexNameLookup(req) |
| 45 | if indexName == "" { |
| 46 | rest.ShowError(w, req, "index name is required", http.StatusBadRequest) |
| 47 | return |
| 48 | } |
| 49 | |
| 50 | indexUUID := req.FormValue("indexUUID") |
| 51 | |
| 52 | requestBody, err := ioutil.ReadAll(req.Body) |
| 53 | if err != nil { |
| 54 | rest.ShowErrorBody(w, nil, fmt.Sprintf("bleve: AnalyzeDoc,"+ |
| 55 | " could not read request body, indexName: %s", |
| 56 | indexName), http.StatusBadRequest) |
| 57 | return |
| 58 | } |
| 59 | |
| 60 | _, _, err = cbgt.GetIndexDef(h.mgr.Cfg(), indexName) |
| 61 | if err != nil { |
| 62 | rest.ShowError(w, req, fmt.Sprintf("bleve: AnalyzeDoc,"+ |
| 63 | " no indexName: %s found, err: %v", |
| 64 | indexName, err), http.StatusBadRequest) |
| 65 | } |
| 66 | |
| 67 | err = AnalyzeDoc(h.mgr, indexName, indexUUID, requestBody, w) |
| 68 | if err != nil { |
| 69 | rest.ShowError(w, req, fmt.Sprintf("bleve: AnalyzeDoc,"+ |
| 70 | " indexName: %s, err: %v", |
| 71 | indexName, err), http.StatusInternalServerError) |
| 72 | return |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func AnalyzeDoc(mgr *cbgt.Manager, indexName, indexUUID string, |
| 77 | req []byte, res io.Writer) error { |
nothing calls this directly
no test coverage detected