1
0
Fork 0

Made ServeStatic() to return an error.

This commit is contained in:
Alexander Andreev 2023-05-28 01:49:21 +04:00
parent 89c2333a4f
commit 9cda541108
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 2 additions and 2 deletions

View File

@ -187,10 +187,10 @@ func (rr *Router) Handler(method, pattern string, handler http.HandlerFunc) erro
// ServeStatic serves a given file system.
//
// 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)
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")
fileServer.ServeHTTP(w, r)
})