diff options
author | Wolfy-J <[email protected]> | 2018-06-13 14:07:58 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-13 14:07:58 +0300 |
commit | 7d77b05901f4b34025a307de2ac4a83ae3162452 (patch) | |
tree | 847574125797cb69d444530cbae59cf345cbe415 /service/http | |
parent | ca95f67317bcf8972b9e669869338a7dc09bf06d (diff) |
minor refactor
Diffstat (limited to 'service/http')
-rw-r--r-- | service/http/handler.go | 2 | ||||
-rw-r--r-- | service/http/service.go | 10 |
2 files changed, 5 insertions, 7 deletions
diff --git a/service/http/handler.go b/service/http/handler.go index 0124a2a4..a4cb6406 100644 --- a/service/http/handler.go +++ b/service/http/handler.go @@ -48,7 +48,7 @@ func (h *Handler) Listen(l func(event int, ctx interface{})) { h.lsn = l } -// Handle serve using PSR-7 requests passed to underlying application. Attempts to serve static files first if enabled. +// middleware serve using PSR-7 requests passed to underlying application. Attempts to serve static files first if enabled. func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // validating request size if h.cfg.MaxRequest != 0 { diff --git a/service/http/service.go b/service/http/service.go index f1712fd2..881c862d 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -11,10 +11,8 @@ import ( // Name contains default svc name. const Name = "http" -type middleware interface { - // Handle must return true if request/response pair is handled withing the mdws. - Handle(w http.ResponseWriter, r *http.Request) bool -} +// must return true if request/response pair is handled withing the middleware. +type middleware func(w http.ResponseWriter, r *http.Request) bool // Service manages rr, http servers. type Service struct { @@ -101,10 +99,10 @@ func (s *Service) Stop() { s.http.Shutdown(context.Background()) } -// Handle handles connection using set of mdws and rr PSR-7 server. +// middleware handles connection using set of mdws and rr PSR-7 server. func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { for _, m := range s.mdws { - if m.Handle(w, r) { + if m(w, r) { return } } |