HandlerFunc provides Martini compatible handler
(w http.ResponseWriter, r *http.Request)
| 293 | |
| 294 | // HandlerFunc provides Martini compatible handler |
| 295 | func (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 |
| 308 | func (c *Cors) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { |