diff options
author | Wolfy-J <[email protected]> | 2018-06-10 20:31:05 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-10 20:31:05 +0300 |
commit | ed3a0f2bb25077c7a32a54ddb3754f04ffbdccf3 (patch) | |
tree | 9a579e6ce81e7af5e3844fbcf590f9c8db26d90a /http/service.go | |
parent | ade5cc504e2b082d0838cc93c3a185246fdc7834 (diff) |
debug mode have been added
Diffstat (limited to 'http/service.go')
-rw-r--r-- | http/service.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/http/service.go b/http/service.go index 81ffb8a2..7835a652 100644 --- a/http/service.go +++ b/http/service.go @@ -18,24 +18,21 @@ type Middleware interface { // Service manages rr, http servers. type Service struct { - cfg *Config - - // todo: multiple listeners - listener func(event int, ctx interface{}) - + cfg *Config + listeners []func(event int, ctx interface{}) middleware []Middleware rr *roadrunner.Server srv *Server http *http.Server } -func (s *Service) Add(m Middleware) { +func (s *Service) AddMiddleware(m Middleware) { s.middleware = append(s.middleware, m) } -// Listen attaches server event watcher. -func (s *Service) Listen(o func(event int, ctx interface{})) { - s.listener = o +// AddListener attaches server event watcher. +func (s *Service) AddListener(l func(event int, ctx interface{})) { + s.listeners = append(s.listeners, l) } // Configure must return configure svc and return true if svc hasStatus enabled. Must return error in case of @@ -114,3 +111,9 @@ func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.srv.ServeHTTP(w, r) } + +func (s *Service) listener(event int, ctx interface{}) { + for _, l := range s.listeners { + l(event, ctx) + } +} |