Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoteAddr ¶
func RemoteAddr(req *http.Request, forwarded *ForwardedHeader) string
RemoteAddr returns the remote address for the HTTP request.
In order:
- if the Forwarded header is set, then the first item in the list's "for" field is used, if it exists. The "for" value is returned even if it is an obfuscated identifier.
- if the X-Real-Ip header is set, then its value is returned.
- if the X-Forwarded-For header is set, then the first value in the comma-separated list is returned.
- otherwise, the host portion of req.RemoteAddr is returned.
func RequestURL ¶
func RequestURL(req *http.Request, forwarded *ForwardedHeader) model.URL
RequestURL returns a model.URL for req.
If req contains an absolute URI, the values will be split and sanitized, but no further processing performed. For all other requests (i.e. most server-side requests), we reconstruct the URL based on various proxy forwarding headers and other request attributes.
Types ¶
type ForwardedHeader ¶
ForwardedHeader holds information extracted from a "Forwarded" HTTP header.
func ParseForwarded ¶
func ParseForwarded(f string) ForwardedHeader
ParseForwarded parses a "Forwarded" HTTP header.
Click to show internal directories.
Click to hide internal directories.