ServeHTTP handles the incoming HTTP request and forwards it to the underlying proxy server. It increments the load counter by 1 before forwarding the request and decrements it by the given value after the request is processed. This method is part of the Proxy struct and implements the http.Handler i
(w http.ResponseWriter, r *http.Request)
| 41 | // - w: The http.ResponseWriter used to write the response back to the client. |
| 42 | // - r: The http.Request representing the incoming request. |
| 43 | func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 44 | atomic.AddUint32(&p.loading, 1) |
| 45 | defer atomic.AddUint32(&p.loading, uint32(value)) |
| 46 | p.proxy.ServeHTTP(w, r) |
| 47 | } |
| 48 | |
| 49 | // GetLoading returns the current loading of the proxy. |
| 50 | func (p *Proxy) GetLoading() uint32 { |
no outgoing calls