Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddHeaderRule ¶
AddHeaderRule represents a header entry. Value supports dynamic "${DOMAIN}".
func (*AddHeaderRule) Add ¶
func (rule *AddHeaderRule) Add(host HostDomain, header http.Header)
Add modifies the header by adding a new header entry. Supports dynamic "${DOMAIN}".
type AddRequestCookieRule ¶
type AddRequestCookieRule struct { PathMatcher *regexp.Regexp CookieAdder CookieAdder }
AddRequestCookieRule represents a rule for adding a new (request) cookie.
func (*AddRequestCookieRule) AddCookie ¶
func (rule *AddRequestCookieRule) AddCookie(host HostDomain, req *http.Request)
AddCookie modifies the request by adding the cookie specified in this rule. Supports the dynamic rule "${DOMAIN}", so a 2nd-level and 3rd-level domain name is needed.
func (*AddRequestCookieRule) Match ¶
func (rule *AddRequestCookieRule) Match(path string) bool
Match tests whether the path matches this rule.
type CookieAdder ¶
CookieAdder is the cookie to be added. CookieAdder.Value can contain "${DOMAIN}" for current domain name.
func (*CookieAdder) Add ¶
func (adder *CookieAdder) Add(host HostDomain, req *http.Request)
Add modifies the request by adding a new cookie in the header. Supports dynamic "${DOMAIN}" in cookie value.
type DirectedLocation ¶
DirectedLocation represents the target location where the router relays to.
type HostDomain ¶
type HostDomain struct { // The host name, e.g. "a.b.example.com:8080" Host string // The 2nd-level domain name, e.g. "example.com" Domain2 string // The 3rd-level domain name, e.g. "b.example.com" Domain3 string }
HostDomain is a compiled set of domain names of a host.
func CompileHostDomain ¶
func CompileHostDomain(host string) HostDomain
CompileHostDomain parses the host name and extracts domain names. For example, a.b.example.com:8080" --> ("example.com", "b.example.com")
type PatchBodyRule ¶
type PatchBodyRule struct { // Matcher is the regex pattern to be replaced Matcher *regexp.Regexp // Replacer is the replacement text repl (the same as in regex.ReplaceAll), // supports "${HOST}" for current host name Replacer []byte }
PatchBodyRule represents a rule to modify a (response) body.
func (*PatchBodyRule) ReplaceAll ¶
func (rule *PatchBodyRule) ReplaceAll(host string, body []byte) []byte
ReplaceAll will search and replace the response body according to the rule.
type PatchHeaderRule ¶
PatchHeaderRule represents a rule for modify an existing header.
func (*PatchHeaderRule) Patch ¶
func (rule *PatchHeaderRule) Patch(host HostDomain, header http.Header)
Patch modifies the header entries that has the same name in the rule, and replace the value according to the rule.
type RequestDispatchRule ¶
type RequestDispatchRule struct { PathMatcher *regexp.Regexp PathReplacer string DstScheme string DstHost string DstServer string }
RequestDispatchRule is a rule to dispatch specific requests.
func (*RequestDispatchRule) Direct ¶
func (rule *RequestDispatchRule) Direct(path string) DirectedLocation
Direct turns a path into an appropriate DirectedLocation for later consumption. Supports the dynamic "${PATH}" in target path.
func (*RequestDispatchRule) Match ¶
func (rule *RequestDispatchRule) Match(path string) bool
Match tells whether the path matches this rule.