Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,20 @@ func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc) {
r.Handler(method, path, handler)
}

// WrapF is an adapter function that converts a http.HandlerFunc into a Handle.
func WrapF(f http.HandlerFunc) Handle {
return func(w http.ResponseWriter, r *http.Request, _ Params) {
f(w, r)
}
}

// WrapF is an adapter function that converts a http.Handler into a Handle.
func WrapH(h http.Handler) Handle {
return func(w http.ResponseWriter, r *http.Request, _ Params) {
h.ServeHTTP(w, r)
}
}

// ServeFiles serves files from the given file system root.
// The path must end with "/*filepath", files are then served from the local
// path /defined/root/dir/*filepath.
Expand Down