connectionTracker is middleware that wraps an http.Handler to track active connections
(next http.Handler)
| 248 | |
| 249 | // connectionTracker is middleware that wraps an http.Handler to track active connections |
| 250 | func connectionTracker(next http.Handler) http.Handler { |
| 251 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 252 | atomic.AddInt32(&activeConnections, 1) |
| 253 | defer atomic.AddInt32(&activeConnections, -1) |
| 254 | next.ServeHTTP(w, r) |
| 255 | }) |
| 256 | } |
| 257 | |
| 258 | // --- HTTP Handler --- |
| 259 | func handler(w http.ResponseWriter, r *http.Request) { |