package martianurl
import "github.com/google/martian/v3/martianurl"
Package martianurl provides utilities for modifying, filtering, and verifying URLs in martian.Proxy.
Index ¶
- func MatchHost(host, match string) bool
- func NewModifier(url *url.URL) martian.RequestModifier
- func NewVerifier(url *url.URL) verify.RequestVerifier
- type Filter
- type Matcher
- func NewMatcher(url *url.URL) *Matcher
- func (m *Matcher) MatchRequest(req *http.Request) bool
- func (m *Matcher) MatchResponse(res *http.Response) bool
- type Modifier
- type RegexMatcher
- func NewRegexMatcher(r *regexp.Regexp) *RegexMatcher
- func (m *RegexMatcher) MatchRequest(req *http.Request) bool
- func (m *RegexMatcher) MatchResponse(res *http.Response) bool
- type URLRegexFilter
- type Verifier
Functions ¶
func MatchHost ¶
MatchHost matches two URL hosts with support for wildcards.
func NewModifier ¶
NewModifier overrides the url of the request.
func NewVerifier ¶
func NewVerifier(url *url.URL) verify.RequestVerifier
NewVerifier returns a new URL verifier.
Types ¶
type Filter ¶
Filter runs modifiers iff the request URL matches all of the segments in url.
func NewFilter ¶
NewFilter constructs a filter that applies the modifer when the request URL matches all of the provided URL segments.
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher is a conditional evaluator of request urls to be used in filters that take conditionals.
func NewMatcher ¶
NewMatcher builds a new url matcher.
func (*Matcher) MatchRequest ¶
MatchRequest retuns true if all non-empty URL segments in m.url match the request URL.
func (*Matcher) MatchResponse ¶
MatchResponse retuns true if all non-empty URL segments in m.url match the request URL.
type Modifier ¶
type Modifier struct {
// contains filtered or unexported fields
}
Modifier alters the request URL fields to match the fields of url and adds a X-Forwarded-Url header that contains the original value of the request URL.
func (*Modifier) ModifyRequest ¶
ModifyRequest sets the fields of req.URL to m.Url if they are not the zero value.
type RegexMatcher ¶
type RegexMatcher struct {
// contains filtered or unexported fields
}
RegexMatcher is a conditional evaluator of request urls to be used in filters that take conditionals.
func NewRegexMatcher ¶
func NewRegexMatcher(r *regexp.Regexp) *RegexMatcher
NewRegexMatcher builds a new url matcher from a compiled Regexp.
func (*RegexMatcher) MatchRequest ¶
func (m *RegexMatcher) MatchRequest(req *http.Request) bool
MatchRequest retuns true if the request URL matches r.
func (*RegexMatcher) MatchResponse ¶
func (m *RegexMatcher) MatchResponse(res *http.Response) bool
MatchResponse retuns true if the response URL matches r.
type URLRegexFilter ¶
URLRegexFilter runs Modifier if the request URL matches the regex, and runs ElseModifier if not. This is not to be confused with url.Filter that does string matching on URL segments.
func NewRegexFilter ¶
func NewRegexFilter(r *regexp.Regexp) *URLRegexFilter
NewRegexFilter constructs a filter that matches on regular expressions.
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier verifies the structure of URLs.
func (*Verifier) ModifyRequest ¶
ModifyRequest verifies that the request URL matches all parts of url. If the value in url is non-empty it must be an exact match.
func (*Verifier) ResetRequestVerifications ¶
func (v *Verifier) ResetRequestVerifications()
ResetRequestVerifications clears all failed request verifications.
func (*Verifier) VerifyRequests ¶
VerifyRequests returns an error if verification for any request failed. If an error is returned it will be of type *martian.MultiError.
Source Files ¶
host.go url_filter.go url_matcher.go url_modifier.go url_regex_filter.go url_regex_matcher.go url_verifier.go
- Version
- v3.2.1
- Published
- May 19, 2021
- Platform
- windows/amd64
- Imports
- 11 packages
- Last checked
- 4 hours ago –
Tools for package owners.