diff options
author | Wolfy-J <[email protected]> | 2018-07-07 20:14:04 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2018-07-07 20:14:04 -0700 |
commit | ad0562981de801ad32b5bfd48cea9c92793a8cc0 (patch) | |
tree | 2b8ee2778ddf5399a1fe9260c0947bf9a194bf80 /service/static | |
parent | afde365ba6210569b7d48dec0c07434a7f8a1fd8 (diff) | |
parent | 466383c72d921aba728de40b60910741e561c1d1 (diff) |
Merge pull request #27 from spiral/feature/arguments
Feature/arguments
Diffstat (limited to 'service/static')
-rw-r--r-- | service/static/service.go | 11 |
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, "/") { |