MCPcopy Create free account
hub / github.com/appleboy/loadbalancer-algorithms / ServeHTTP

Method ServeHTTP

proxy/proxy.go:43–47  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

41// - w: The http.ResponseWriter used to write the response back to the client.
42// - r: The http.Request representing the incoming request.
43func (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.
50func (p *Proxy) GetLoading() uint32 {

Callers 1

TestProxy_ServeHTTPFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestProxy_ServeHTTPFunction · 0.76