MCPcopy
hub / github.com/PatchMon/PatchMon / rateLimitClientIP

Function rateLimitClientIP

server-source-code/internal/middleware/ratelimit.go:177–189  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

175}
176
177func rateLimitClientIP(r *http.Request) string {
178 if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
179 if idx := strings.Index(xff, ","); idx != -1 {
180 return strings.TrimSpace(xff[:idx])
181 }
182 return strings.TrimSpace(xff)
183 }
184 host, _, _ := strings.Cut(r.RemoteAddr, ":")
185 if host != "" {
186 return host
187 }
188 return r.RemoteAddr
189}

Callers 2

RateLimitFunction · 0.85
RateLimitAgentByAPIIDFunction · 0.85

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected