From 9cda541108517d2cc64221acd40ff60b78eae4a2 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 28 May 2023 01:49:21 +0400 Subject: [PATCH] Made ServeStatic() to return an error. --- httpr.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpr.go b/httpr.go index d15edbe..64ccbab 100644 --- a/httpr.go +++ b/httpr.go @@ -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) })