MCPcopy
hub / github.com/rs/cors / HandlerFunc

Method HandlerFunc

cors.go:295–305  ·  view source on GitHub ↗

HandlerFunc provides Martini compatible handler

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

293
294// HandlerFunc provides Martini compatible handler
295func (c *Cors) HandlerFunc(w http.ResponseWriter, r *http.Request) {
296 if r.Method == http.MethodOptions && r.Header.Get("Access-Control-Request-Method") != "" {
297 c.logf("HandlerFunc: Preflight request")
298 c.handlePreflight(w, r)
299
300 w.WriteHeader(c.optionsSuccessStatus)
301 } else {
302 c.logf("HandlerFunc: Actual request")
303 c.handleActualRequest(w, r)
304 }
305}
306
307// Negroni compatible interface
308func (c *Cors) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {

Callers 9

cors_test.goFile · 0.80
TestSpecFunction · 0.80
HandlerMethod · 0.80
mainFunction · 0.80
mainFunction · 0.80
buildMethod · 0.80

Calls 4

logfMethod · 0.95
handlePreflightMethod · 0.95
handleActualRequestMethod · 0.95
WriteHeaderMethod · 0.80