(r *http.Request)
| 175 | } |
| 176 | |
| 177 | func 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 | } |
no test coverage detected