summaryrefslogtreecommitdiff
path: root/plugins/http/plugin.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-25 12:33:50 +0300
committerValery Piashchynski <[email protected]>2020-11-25 12:33:50 +0300
commit2918cfca6d9579125257bfc9f5655537a63ec82a (patch)
treef0f4221eca331a27032d923b512df2a567c4ebe6 /plugins/http/plugin.go
parent4f54d3a9d4b9ac65ad47509372f63653b7b973a0 (diff)
Update CreateListener function, simplifications
Diffstat (limited to 'plugins/http/plugin.go')
-rw-r--r--plugins/http/plugin.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index b37a9700..e58f9359 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -268,12 +268,18 @@ func (s *Plugin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
r = attributes.Init(r)
+ // protect the case, when user send Reset and we are replacing handler with pool
+ s.Lock()
+ f := s.handler.ServeHTTP
+ s.Unlock()
// chaining middleware
- f := s.handler.ServeHTTP
- for _, m := range s.mdwr {
- f = m(f)
+ if len(s.mdwr) > 0 {
+ for i := 0; i < len(s.mdwr); i++ {
+ f = s.mdwr[i](f)
+ }
}
+
f(w, r)
}