Skip to content
Permalink
Browse files

Respond to HEAD

  • Loading branch information
DarthSim committed Jan 30, 2020
1 parent 03bc5c8 commit aa8cff62f4bdcda9d6453b672a308caa486c97b4
Showing with 7 additions and 2 deletions.
  1. +4 −0 router.go
  2. +3 −2 server.go
@@ -64,6 +64,10 @@ func (r *router) OPTIONS(prefix string, handler routeHandler, exact bool) {
r.Add(http.MethodOptions, prefix, handler, exact)
}

func (r *router) HEAD(prefix string, handler routeHandler, exact bool) {
r.Add(http.MethodHead, prefix, handler, exact)
}

func (r *router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
req = req.WithContext(setTimerSince(req.Context()))

@@ -25,7 +25,8 @@ func buildRouter() *router {
r.GET("/health", handleHealth, true)
r.GET("/favicon.ico", handleFavicon, true)
r.GET("/", withCORS(withSecret(handleProcessing)), false)
r.OPTIONS("/", withCORS(handleOptions), false)
r.HEAD("/", withCORS(handleHead), false)
r.OPTIONS("/", withCORS(handleHead), false)

return r
}
@@ -128,7 +129,7 @@ func handleHealth(reqID string, rw http.ResponseWriter, r *http.Request) {
rw.Write(imgproxyIsRunningMsg)
}

func handleOptions(reqID string, rw http.ResponseWriter, r *http.Request) {
func handleHead(reqID string, rw http.ResponseWriter, r *http.Request) {
logResponse(reqID, r, 200, nil, nil, nil)
rw.WriteHeader(200)
}

0 comments on commit aa8cff6

Please sign in to comment.
You can’t perform that action at this time.