martianurl

package
v2.1.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package martianurl provides utilities for modifying, filtering, and verifying URLs in martian.Proxy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchHost

func MatchHost(host, match string) bool

MatchHost matches two URL hosts with support for wildcards.

func NewModifier

func NewModifier(url *url.URL) martian.RequestModifier

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

type Filter struct {
	*filter.Filter
}

Filter runs modifiers iff the request URL matches all of the segments in url.

func NewFilter

func NewFilter(u *url.URL) *Filter

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

func NewMatcher(url *url.URL) *Matcher

NewMatcher builds a new url matcher.

func (*Matcher) MatchRequest

func (m *Matcher) MatchRequest(req *http.Request) bool

MatchRequest retuns true if all non-empty URL segments in m.url match the request URL.

func (*Matcher) MatchResponse

func (m *Matcher) MatchResponse(res *http.Response) bool

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

func (m *Modifier) ModifyRequest(req *http.Request) error

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

type URLRegexFilter struct {
	*filter.Filter
}

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

func (v *Verifier) ModifyRequest(req *http.Request) error

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

func (v *Verifier) VerifyRequests() error

VerifyRequests returns an error if verification for any request failed. If an error is returned it will be of type *martian.MultiError.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL