MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / httpRemoteIP

Function httpRemoteIP

pkg/ratelimit/http.go:26–32  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

24const httpXRealIPHeader = "X-Real-IP"
25
26func 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()

Callers 1

httpRequestResourceFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected