Documentation ¶
Overview ¶
Package request is a generated GoMock package.
Index ¶
- Variables
- func CopyURL(i *url.URL) *url.URL
- func OverrideURL(dst, src *url.URL)
- func WriteJSON(req *http.Request, msg interface{}) error
- type BasicAuthConfig
- type MockPreparer
- type MockPreparerMockRecorder
- type PrepareFunc
- type Preparer
- func BasicAuth(cfg *BasicAuthConfig) Preparer
- func Body() Preparer
- func CombinePreparer(preparers ...Preparer) Preparer
- func ExtractURI(reset bool) Preparer
- func ForwardedFor() Preparer
- func HTTPProtocol(major, minor int) Preparer
- func Headers(overrides map[string][]string) Preparer
- func HeadersPreparer(h func(http.Header) error) Preparer
- func Host(host *string) Preparer
- func Proxy(cfg *ProxyConfig) (Preparer, error)
- func RemoveConnectionHeaders() Preparer
- func RemoveHopByHopHeaders() Preparer
- func Request(baseReq *http.Request) Preparer
- func URL(u *url.URL) Preparer
- func UserAgent(agent string) Preparer
- type ProxyConfig
Constants ¶
This section is empty.
Variables ¶
var NoopPreparer = PrepareFunc(func(req *http.Request) (*http.Request, error) { return req, nil })
Functions ¶
func OverrideURL ¶
Types ¶
type BasicAuthConfig ¶
type MockPreparer ¶
type MockPreparer struct {
// contains filtered or unexported fields
}
MockPreparer is a mock of Preparer interface.
func NewMockPreparer ¶
func NewMockPreparer(ctrl *gomock.Controller) *MockPreparer
NewMockPreparer creates a new mock instance.
func (*MockPreparer) EXPECT ¶
func (m *MockPreparer) EXPECT() *MockPreparerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockPreparerMockRecorder ¶
type MockPreparerMockRecorder struct {
// contains filtered or unexported fields
}
MockPreparerMockRecorder is the mock recorder for MockPreparer.
func (*MockPreparerMockRecorder) Prepare ¶
func (mr *MockPreparerMockRecorder) Prepare(arg0 interface{}) *gomock.Call
Prepare indicates an expected call of Prepare.
type PrepareFunc ¶
PrepareFunc is a method that implements the Preparer interface.
type Preparer ¶
Preparer is the interface that allows to prepare a http.Request
Prepare accepts and possibly modifies a Request (e.g., adding Headers). Implementations must ensure to not share or hold per-invocation state since Preparers may be shared and re-used.
func BasicAuth ¶
func BasicAuth(cfg *BasicAuthConfig) Preparer
BasicAuth sets Authorization header "Basic <username>:<password>" If header is already set then does nothing if User is set on request URL then set username, password to the values of the URL
func CombinePreparer ¶
CombinePreparer combines multiple preparers into a single one
func ExtractURI ¶
ExtractURI parses request URI, updates request URL and optional reset URI
func ForwardedFor ¶
func ForwardedFor() Preparer
ForwardedFor populates "X-Forwarded-For" header with the client IP address In case, "X-Forwarded-For" was already populated (e.g. if we are not the first proxy) then retains prior X-Forwarded-For information as a comma+space separated list and fold multiple headers into one.
func Host ¶
Host set request Host This is useful when proxying request (to set the request host to match downstream server) If host is nil then it sets the Host to request URL host
func Proxy ¶
func Proxy(cfg *ProxyConfig) (Preparer, error)
Proxy creates a preparer for proxying request
func RemoveConnectionHeaders ¶
func RemoveConnectionHeaders() Preparer
RemoveConnectionHeaders removes "Connection" header See RFC 7230, section 6.1
func RemoveHopByHopHeaders ¶
func RemoveHopByHopHeaders() Preparer
RemoveHopByHopHeaders remove Hop-by-hop headers from the request These headers are meaningful only for a single transport-level connection, and must not be retransmitted by proxies or cached (c.f. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers)
type ProxyConfig ¶
type ProxyConfig struct { Addr string `json:"addr,omitempty"` PassHostHeader *bool `json:"passHostHeader,omitempty"` BasicAuth *BasicAuthConfig `json:"basicAuth,omitempty"` Headers map[string][]string `json:"headers,omitempty"` }
func (*ProxyConfig) SetDefault ¶
func (cfg *ProxyConfig) SetDefault() *ProxyConfig