Documentation
¶
Index ¶
- func AddPathSegment(u *url.URL, newpath string)
- func AddQueryParam(u *url.URL, key string, value interface{})
- func Clone(u *url.URL) *url.URL
- func ExpandPath(u *url.URL, values ExpandMap) error
- func IsDomain(u *url.URL, domain string) bool
- func IsDomainOrSubdomainOf(u *url.URL, domain string) bool
- func IsSubdomainOf(u *url.URL, domain string) bool
- func MustParse(rawurl string) *url.URL
- func RemovePathSegment(u *url.URL, index int)
- func SetQueryParam(u *url.URL, key string, value interface{})
- type ExpandMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPathSegment ¶
AddPathSegment adds a path segment. It is safe to use this function with externally controlled data; newpath is escaped. A malicious user cannot leverage tricks involving ".." or "/". An empty newpath is ignored.
func AddQueryParam ¶
AddQueryParam adds the value to key in the query parameters. It appends to any existing values associated with key.
func ExpandPath ¶
ExpandPath enables replacing a URL template with concrete values. E.g. ExpandPath(http://example.com/{a}/xyz/{b}, {"a": "foo", "b": 123}) results in http://example.com/foo/xyz/123
func IsDomain ¶
IsDomain checks if a domain matches a url.URL. E.g. given http://www.example.com/, IsDomain returns true only for "www.example.com".
func IsDomainOrSubdomainOf ¶
IsDomainOrSubdomainOf checks if a url.URL is a domain or subdomain of a given domain. E.g. given http://www.example.com/, IsDomainOrSubdomainOf returns true for "www.example.com", "example.com", and "com".
func IsSubdomainOf ¶
IsSubdomainOf checks if a url.URL is a subdomain of a given domain. E.g. given http://www.example.com/, IsSubdomainOf returns true for "example.com", as well as for "com".
func RemovePathSegment ¶
RemovePathSegment drops a path segment at a given segment, counting from 0. E.g. RemovePathSegment(http://example.com/foo/bar/xyz, 1) would result in http://example.com/foo/xyz
func SetQueryParam ¶
SetQueryParam sets the key to value in the query parameters. It replaces any existing values.