Documentation ¶
Overview ¶
Package urlmatcher defines interface for URL matching.
Index ¶
- type AndMatcher
- type Matcher
- func HasEscapedPathPrefix(prefix string) Matcher
- func HasEscapedPathRegexp(re *regexp.Regexp) Matcher
- func HasHost(host string) Matcher
- func HasHostname(hostname string) Matcher
- func HasHostnameSuffix(suffix string) Matcher
- func HasRawQueryRegexp(re *regexp.Regexp) Matcher
- func HasScheme(scheme string) Matcher
- type MatcherFunc
- type NotMatcher
- type OrMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AndMatcher ¶
type AndMatcher []Matcher
AndMatcher matches the URL u if u matches all of the given Matchers.
An empty AndMatcher matches all URLs.
func (AndMatcher) Match ¶
func (am AndMatcher) Match(u *url.URL) bool
Match calls Matchers in order and returns true if all of them return true. It stops the evaluation and returns false immediately when some Matcher returns false; the subsequent Matchers will not be called (short-circuit).
Match returns true if am is empty.
type Matcher ¶
Matcher checks whether the given URL meets condition(s).
func HasEscapedPathPrefix ¶
HasEscapedPathPrefix matches the URL u if u.EscapedPath() starts with prefix.
func HasEscapedPathRegexp ¶
HasEscapedPathRegexp matches the URL u if u.EscapedPath() matches the provided Regexp re. Note it just uses re.MatchString to determine the matching, so partial matches are considered as a match. If you want to match your pattern against the entire u.EscapedPath(), enclose it with `\A(?:...)\z`.
func HasHost ¶
HasHost matches the URL u if u.Host is equal to host. ASCII letters are compared in a case-insensitive manner as specified in RFC 4343.
Note u.Host may include a port number. To exclude it from matching, use HasHostname instead.
func HasHostname ¶
HasHostname matches the URL u if u.Hostname() is equal to hostname. It does not inspect the port number, unlike HasHost. ASCII letters are compared in a case-insensitive manner as specified in RFC 4343.
func HasHostnameSuffix ¶
HasHostnameSuffix matches the URL u if u.Hostname() ends with suffix. If suffix has a leading dot ("."), the Matcher matches strictly the subdomains. Otherwise the Matcher matches the exact domain as well. In either case, the Matcher does not match any domains which are not a subdomain of suffix. For example:
- ".example.com" matches "www.example.com" but not "example.com".
- "example.com" matches both "www.example.com" and "example.com".
- Neither ".example.com" nor "exmple.com" matches "counterexample.com".
ASCII letters are compared in a case-insensitive manner as specified in RFC 4343.
func HasRawQueryRegexp ¶
HasRawQueryRegexp matches the URL u if u.RawQuery matches the provided Regexp re. Note it just uses re.MatchString to determine the matching, so partial matches are considered as a match. If you want to match your pattern against the entire u.RawQuery, enclose it with `\A(?:...)\z`.
type MatcherFunc ¶
MatcherFunc turns an ordinary function into a Matcher. If f is a function with the appropriate signature, MatcherFunc(f) is a Matcher calling f.
type OrMatcher ¶
type OrMatcher []Matcher
OrMatcher matches the URL u if u matches at least one of the given Matchers.
An empty OrMatcher matches no URLs.