Documentation ¶
Overview ¶
Package port provides utilities for modifying and filtering based on the port of request URLs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter runs modifiers iff the port in the request URL matches port.
func NewFilter ¶
NewFilter returns a filter that executes modifiers if the port of request matches port.
func (*Filter) ModifyRequest ¶
ModifyRequest runs the modifier if the port matches the provided port.
func (*Filter) ModifyResponse ¶
ModifyResponse runs the modifier if the request URL matches urlMatcher.
func (*Filter) SetRequestModifier ¶
func (f *Filter) SetRequestModifier(reqmod martian.RequestModifier)
SetRequestModifier sets the request modifier.
func (*Filter) SetResponseModifier ¶
func (f *Filter) SetResponseModifier(resmod martian.ResponseModifier)
SetResponseModifier sets the response modifier.
type Modifier ¶
type Modifier struct {
// contains filtered or unexported fields
}
Modifier alters the request URL and Host header to use the provided port. Only one of port, defaultForScheme, or remove may be specified. Whichever is set last is the one that will take effect. If remove is true, remove the port from the host string ('example.com'). If defaultForScheme is true, explicitly specify 80 for HTTP or 443 for HTTPS ('http://example.com:80'). Do nothing for a scheme that is not 'http' or 'https'. If port is specified, explicitly add it to the host string ('example.com:1234'). If port is zero and the other fields are false, the request will not be modified.
func NewModifier ¶
func NewModifier() *Modifier
NewModifier returns a RequestModifier that can be configured to alter the request URL and Host header's port. One of DefaultPortForScheme, UsePort, or RemovePort should be called to configure this modifier.
func (*Modifier) DefaultPortForScheme ¶
func (m *Modifier) DefaultPortForScheme()
DefaultPortForScheme configures the modifier to explicitly specify 80 for HTTP or 443 for HTTPS ('http://example.com:80'). The modifier will not modify requests with a scheme that is not 'http' or 'https'. This overrides any previous configuration for this modifier.
func (*Modifier) ModifyRequest ¶
ModifyRequest alters the request URL and Host header to modify the port as specified. See docs for Modifier for details.
func (*Modifier) RemovePort ¶
func (m *Modifier) RemovePort()
RemovePort configures the modifier to remove the port from the host string ('example.com'). This overrides any previous configuration for this modifier.