diff options
author | Wolfy-J <[email protected]> | 2018-07-07 19:42:31 -0700 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-07-07 19:42:31 -0700 |
commit | 806b89a1ac24cf6d173f697c9261eed5efa68c3f (patch) | |
tree | e77ff0d9bdf535881ce553574c42d76240ac11a2 /service/static | |
parent | 98f7ce699b559afd74d4e9d607e64b9a8367d762 (diff) |
new middleware format
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, "/") { |