(r *http.Request)
| 24 | const httpXRealIPHeader = "X-Real-IP" |
| 25 | |
| 26 | func httpRemoteIP(r *http.Request) string { |
| 27 | if xRealIP := r.Header.Get(httpXRealIPHeader); xRealIP != "" { |
| 28 | return xRealIP |
| 29 | } |
| 30 | host, _, _ := net.SplitHostPort(r.RemoteAddr) |
| 31 | return host |
| 32 | } |
| 33 | |
| 34 | // HTTPMiddleware is an HTTP middleware that rate limits by remote IP and the request URL. |
| 35 | // The remote IP is retrieved by the X-Real-IP header. Use this middleware after webmiddleware.ProxyHeaders() |
no test coverage detected