Skip to content

Commit

Permalink
support head and patch HTTP request methods
Browse files Browse the repository at this point in the history
support head and patch http request methods
  • Loading branch information
AlaaAttya committed Jun 28, 2019
2 parents 941b70c + f9c0e97 commit 2b6f1bd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions fdhttp/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ func (r *Router) StdOPTIONS(path string, handler http.HandlerFunc) *Endpoint {
return r.StdHandler("OPTIONS", path, handler)
}

// StdHEAD register a standard http.HandlerFunc to handle HEAD method
func (r *Router) StdHEAD(path string, handler http.HandlerFunc) *Endpoint {
return r.StdHandler("HEAD", path, handler)
}

// StdPATCH register a standard http.HandlerFunc to handle PATCH method
func (r *Router) StdPATCH(path string, handler http.HandlerFunc) *Endpoint {
return r.StdHandler("PATCH", path, handler)
}

// Handler register the method and path with fdhttp.EndpointFunc
func (r *Router) Handler(method, path string, fn EndpointFunc) *Endpoint {
prefix := make([]string, 0)
Expand Down Expand Up @@ -303,6 +313,16 @@ func (r *Router) OPTIONS(path string, fn EndpointFunc) *Endpoint {
return r.Handler("OPTIONS", path, fn)
}

// HEAD register a fdhttp.EndpointFunc to handle HEAD method
func (r *Router) HEAD(path string, fn EndpointFunc) *Endpoint {
return r.Handler("HEAD", path, fn)
}

// PATCH register a fdhttp.EndpointFunc to handle PATCH method
func (r *Router) PATCH(path string, fn EndpointFunc) *Endpoint {
return r.Handler("PATCH", path, fn)
}

// ServeHTTP makes this struct a valid implementation of http.Handler
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if r.rootHandler == nil {
Expand Down

0 comments on commit 2b6f1bd

Please sign in to comment.