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

Method ServeHTTP

rest.go:152–190  ·  view source on GitHub ↗
(
	w http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

150}
151
152func (c *AuthVersionHandler) ServeHTTP(
153 w http.ResponseWriter, req *http.Request) {
154 defer func() {
155 if err := recover(); err != nil {
156 buf := make([]byte, 2048)
157 n := runtime.Stack(buf, false)
158 cbgt.PublishCrashEvent(map[string]interface{}{
159 "stackTrace": string(buf[:n]),
160 "crashError": fmt.Sprintf("%v", err),
161 })
162 }
163 }()
164 if err := CheckAPIVersion(w, req); err != nil {
165 return
166 }
167
168 path := ""
169 if c.H != nil {
170 hwrm, ok := c.H.(*rest.HandlerWithRESTMeta)
171 if ok && hwrm.RESTMeta != nil {
172 path = hwrm.RESTMeta.Opts["_path"]
173 }
174 }
175
176 c.doAudit(req, path)
177
178 wEx := wrapResponseWriter(w)
179
180 ok, username := checkAPIAuth(c, wEx, req, path)
181 if !ok {
182 return
183 }
184
185 if c.H != nil {
186 c.H.ServeHTTP(wEx, req)
187 }
188
189 completeRequest(username, path, req, wEx.Length())
190}
191
192func (c *AuthVersionHandler) doAudit(req *http.Request, path string) {
193 if c.adtSvc == nil {

Callers 8

mainStartFunction · 0.95
testRESTHandlersFunction · 0.45
TestCreateIndexTwoNodesFunction · 0.45
testCreateIndex1NodeFunction · 0.45
TestSourceNamesFromReqFunction · 0.45
TestPreparePermsFunction · 0.45

Calls 6

doAuditMethod · 0.95
CheckAPIVersionFunction · 0.85
wrapResponseWriterFunction · 0.85
checkAPIAuthFunction · 0.85
completeRequestFunction · 0.85
LengthMethod · 0.80