MCPcopy Create free account
hub / github.com/couchbase/cbft / ServeHTTP

Method ServeHTTP

pindex_rest_handlers.go:42–74  ·  view source on GitHub ↗
(
	w http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

40}
41
42func (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
76func AnalyzeDoc(mgr *cbgt.Manager, indexName, indexUUID string,
77 req []byte, res io.Writer) error {

Callers

nothing calls this directly

Calls 2

AnalyzeDocFunction · 0.85
GetIndexDefMethod · 0.65

Tested by

no test coverage detected