Documentation
¶
Index ¶
- func All(r *http.Request) url.Values
- func Array(r *http.Request, key string, defaultValue []string) []string
- func Has(r *http.Request, key string) bool
- func HasGet(r *http.Request, key string) bool
- func HasPost(r *http.Request, key string) bool
- func IP(r *http.Request) string
- func Map(r *http.Request, key string) map[string]string
- func Maps(r *http.Request, key string, defaultValue []map[string]string) []map[string]string
- func Subdomain(r *http.Request) (string, error)
- func Value(r *http.Request, key string) string
- func ValueOr(r *http.Request, key string, defaultValue string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
All returns all request variables as a url.Values object
Parameters:
- r *http.Request: HTTP request
Returns:
- url.Values: all request variables
func Array ¶
Array returns an array from the request
Parameters:
- r *http.Request: HTTP request
- key string: key to get array for
- defaultValue []string: default value to return if key does not exist
Returns:
- []string: array for key, or default value if not exists
func Has ¶
Has returns true if GET or POST key exists
Parameters:
- r *http.Request: HTTP request
- key string: key to check if exists
Returns:
- bool: true if key exists
func HasGet ¶
HasGet returns true if GET key exists
Parameters:
- r *http.Request: HTTP request
- key string: key to check if exists
Returns:
- bool: true if key exists
func HasPost ¶
HasPost returns true if POST key exists
Parameters:
- r *http.Request: HTTP request
- key string: key to check if exists
Returns:
- bool: true if key exists
func Map ¶
Map returns a map from the request
Parameters:
- r *http.Request: HTTP request
- key string: key to get map for
Returns:
- map[string]string: map for key
func Subdomain ¶ added in v0.0.3
Subdomain finds the subdomain in the host of the given request.
Business logic: - extract the host from the request - if the host is "localhost", return an empty string - if there is no dot in the host, return an empty string - otherwise, return the part of the host before the first dot
Parameters:
- r (*http.Request): The HTTP request from which to extract the subdomain.
Returns:
- string: the subdomain, or an empty string if none found.
- error: an error if any, otherwise nil.
func Value ¶
Value returns a POST or GET key, or empty string if not exists
Parameters:
- r *http.Request: HTTP request
- key string: key to get value for
Returns:
- string: value for key, or empty string if not exists
Types ¶
This section is empty.