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

Method ServeHTTP

http/index_get.go:26–53  ·  view source on GitHub ↗
(w http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

24}
25
26func (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}

Callers

nothing calls this directly

Calls 4

showErrorFunction · 0.85
IndexByNameFunction · 0.85
mustEncodeFunction · 0.70
MappingMethod · 0.45

Tested by

no test coverage detected