Made ServeStatic() to return an error.
This commit is contained in:
parent
89c2333a4f
commit
9cda541108
4
httpr.go
4
httpr.go
@ -187,10 +187,10 @@ func (rr *Router) Handler(method, pattern string, handler http.HandlerFunc) erro
|
|||||||
// ServeStatic serves a given file system.
|
// ServeStatic serves a given file system.
|
||||||
//
|
//
|
||||||
// Path should end with /*filepath to work.
|
// Path should end with /*filepath to work.
|
||||||
func (rr *Router) ServeStatic(path string, root http.FileSystem) {
|
func (rr *Router) ServeStatic(path string, root http.FileSystem) error {
|
||||||
fileServer := http.FileServer(root)
|
fileServer := http.FileServer(root)
|
||||||
|
|
||||||
rr.Handler(http.MethodGet, path, func(w http.ResponseWriter, r *http.Request) {
|
return rr.Handler(http.MethodGet, path, func(w http.ResponseWriter, r *http.Request) {
|
||||||
r.URL.Path = Param(r, "filepath")
|
r.URL.Path = Param(r, "filepath")
|
||||||
fileServer.ServeHTTP(w, r)
|
fileServer.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user