diff options
author | Valery Piashchynski <[email protected]> | 2020-11-18 18:15:09 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-11-18 18:15:09 +0300 |
commit | 8fab090abc369237d5f9be2ee676005b24c2a470 (patch) | |
tree | 9f7fc358b66357f0218b8256d8073616995b91db /plugins/http/plugin.go | |
parent | 4ccd58fc363264d24f642ab7e0ccfe6538a0b91c (diff) |
Handler test
Diffstat (limited to 'plugins/http/plugin.go')
-rw-r--r-- | plugins/http/plugin.go | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go index e5ccabc4..fc08a01f 100644 --- a/plugins/http/plugin.go +++ b/plugins/http/plugin.go @@ -47,13 +47,13 @@ type Plugin struct { configurer config.Configurer log log.Logger - mdwr []middleware - listeners []util.EventListener + mdwr []middleware + listener util.EventListener pool roadrunner.Pool server factory.Server - //controller roadrunner.Controller - handler *Handler + + handler Handler http *http.Server https *http.Server @@ -68,7 +68,7 @@ func (s *Plugin) AddMiddleware(m middleware) { // AddListener attaches server event controller. func (s *Plugin) AddListener(listener util.EventListener) { // save listeners for Reset - s.listeners = append(s.listeners, listener) + s.listener = listener s.pool.AddListener(listener) } @@ -82,7 +82,6 @@ func (s *Plugin) Init(cfg config.Configurer, log log.Logger, server factory.Serv } s.configurer = cfg - s.listeners = make([]util.EventListener, 0, 1) s.log = log // Set needed env vars @@ -141,8 +140,21 @@ func (s *Plugin) Serve() chan error { // s.pool.Attach(s.controller) //} - s.handler = &Handler{cfg: s.cfg, rr: s.pool} - //s.handler.Listen(s.throw) + var err error + s.handler, err = NewHandler( + s.cfg.MaxRequestSize, + *s.cfg.Uploads, + s.cfg.cidrs, + s.pool, + ) + if err != nil { + errCh <- errors.E(op, err) + return errCh + } + + if s.listener != nil { + s.handler.AddListener(s.listener) + } if s.cfg.EnableHTTP() { if s.cfg.EnableH2C() { @@ -155,7 +167,7 @@ func (s *Plugin) Serve() chan error { if s.cfg.EnableTLS() { s.https = s.initSSL() if s.cfg.SSL.RootCA != "" { - err := s.appendRootCa() + err = s.appendRootCa() if err != nil { errCh <- errors.E(op, err) return errCh @@ -464,8 +476,7 @@ func (s *Plugin) Reset() error { } // restore original listeners - for i := 0; i < len(s.listeners); i++ { - s.pool.AddListener(s.listeners[i]) - } + s.pool.AddListener(s.listener) + return nil } |