Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Router.ServeFiles accepts route options
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Apr 9, 2020
1 parent 8e564be commit 6fc94cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ under development
- Move contextPool out from router.
- Add middlewareStatePool.
- Add Context.DefaultQuery.
- Router.ServeFiles accepts route options.

v1.9.0 April 4, 2020
--------------------
Expand Down
4 changes: 2 additions & 2 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (r *Router) HandlerFunc(method, path string, f http.HandlerFunc, opts ...Ro
// To use the operating system's file system implementation,
// use http.Dir:
// router.ServeFiles("/src/*filepath", http.Dir("/var/www"))
func (r *Router) ServeFiles(path string, root http.FileSystem) {
func (r *Router) ServeFiles(path string, root http.FileSystem, opts ...RouteOption) {
if len(path) < 10 || path[len(path)-10:] != "/*filepath" {
panic("path must end with /*filepath in path '" + path + "'")
}
Expand All @@ -277,7 +277,7 @@ func (r *Router) ServeFiles(path string, root http.FileSystem) {
ctx.Request.URL.Path = ctx.Params.String("filepath")
fileServer.ServeHTTP(ctx.Response, ctx.Request)
return nil
})
}, opts...)
}

// Lookup allows the manual lookup of a method + path combo.
Expand Down

0 comments on commit 6fc94cb

Please sign in to comment.