Documentation ¶
Index ¶
- func BaseURL(r *http.Request) string
- func Host(r *http.Request) string
- func InPath(r *http.Request, path string, options ...string) bool
- func IsFormRequest(r *http.Request) bool
- func IsJSONRequest(r *http.Request) bool
- func IsSecure(r *http.Request) bool
- func IsXMLHttpRequest(r *http.Request) bool
- func Method(r *http.Request) string
- func Port(r *http.Request) string
- func Referer(r *http.Request) string
- func RemoteAddr(r *http.Request) string
- func Scheme(r *http.Request) string
- func SchemeHostPort(r *http.Request) (string, string, string)
- func URLPath(r *http.Request) string
- func UserAgent(r *http.Request) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InPath ¶
InPath returns true if the current request path matches the given path.
Parameters: - r: *http.Request - the current HTTP request - path: string - the path to match against the request path - options: ...string - optional parameters for matching the path
Returns: - bool: true if the request path matches the given path, false otherwise
Options: - exact: matches the exact path - contains: matches if the path contains the given path - prefix: matches if the path starts with the given path - suffix: matches if the path ends with the given path
func IsFormRequest ¶
IsFormRequest returns true if the request has a Content-Type of application/x-www-form-urlencoded
func IsJSONRequest ¶
IsJSONRequest returns true if the request has a Content-Type of application/json
func IsXMLHttpRequest ¶
IsXMLHttpRequest returns true if the request is an XMLHttpRequest (e.g. via fetch)
func RemoteAddr ¶
RemoteAddr returns the client's IP address extracted from the given http.Request. If the server is behind a proxy and the x-forwarded-for header is set, it will return the first IP address in the list. Otherwise, it will check for the x-real-ip header and return its value. If neither header is set, it will return the remote address of the request.
func SchemeHostPort ¶
SchemeHostPort returns the scheme, host, and port for the given request. If behind a proxy and the X-Forwarded-Proto, X-Forwarded-Host, and/or X-Forwarded-Port headers are set, they will be used.
Types ¶
This section is empty.