summaryrefslogtreecommitdiff
path: root/service/static
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-07-07 20:14:04 -0700
committerGitHub <[email protected]>2018-07-07 20:14:04 -0700
commitad0562981de801ad32b5bfd48cea9c92793a8cc0 (patch)
tree2b8ee2778ddf5399a1fe9260c0947bf9a194bf80 /service/static
parentafde365ba6210569b7d48dec0c07434a7f8a1fd8 (diff)
parent466383c72d921aba728de40b60910741e561c1d1 (diff)
Merge pull request #27 from spiral/feature/arguments
Feature/arguments
Diffstat (limited to 'service/static')
-rw-r--r--service/static/service.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/service/static/service.go b/service/static/service.go
index 2324dcd1..add242e4 100644
--- a/service/static/service.go
+++ b/service/static/service.go
@@ -56,7 +56,16 @@ func (s *Service) Serve() error { return nil }
func (s *Service) Stop() {}
// middleware must return true if request/response pair is handled within the middleware.
-func (s *Service) middleware(w http.ResponseWriter, r *http.Request) bool {
+func (s *Service) middleware(f http.HandlerFunc) http.HandlerFunc {
+ // Define the http.HandlerFunc
+ return func(w http.ResponseWriter, r *http.Request) {
+ if !s.handleStatic(w, r) {
+ f(w, r)
+ }
+ }
+}
+
+func (s *Service) handleStatic(w http.ResponseWriter, r *http.Request) bool {
fPath := r.URL.Path
if !strings.HasPrefix(fPath, "/") {