Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HeaderMap ¶ added in v2.6.0
func (HeaderMap) HeaderMap ¶ added in v2.6.0
HeaderMap returns HeaderMap correspondence of this instance.
func (HeaderMap) Map ¶ added in v2.6.0
Map returns the map correspondence of this instance. The returned value can be used as an argument to NewHeaders to create an identical Headers.
type HeaderStringer ¶
HeaderStringer turns a http.Header into a fmt.Stringer. It is useful when it's desired to defer string formatting of the header depending on loglevel, for instance:
dlog.Debugf(c, "Header = %s", HeaderStringer(header))
would not perform the actual formatting unless the loglevel is DEBUG or higher.
func (HeaderStringer) String ¶
func (s HeaderStringer) String() string
String formats the Header to a readable multi-line string.
type Headers ¶
type Headers interface { // Map returns the map correspondence of this instance. The returned value can be // used as an argument to NewHeaders to create an identical Headers. Map() map[string]string // HeaderMap returns HeaderMap correspondence of this instance. HeaderMap() HeaderMap // Matches returns true if all Value matchers in this instance are matched by the given http.Header. // Header name comparison is made using the textproto.CanonicalMIMEHeaderKey form of the keys. Matches(header http.Header) bool }
Headers uses a set of Value matchers to match a http.Header.
type Request ¶
type Request interface { fmt.Stringer // Headers returns Headers of this instance. Headers() Headers // Map returns the map correspondence of this instance. The returned value can be // used as an argument to NewRequest to create an identical Request. Map() map[string]string // Matches returns true if both the path Value matcher and the Headers matcher in this instance are // matched by the given http.Request. Matches(path string, headers http.Header) bool // Path returns the path Path() Value }
The Request matcher uses a Value matcher and a Headers matcher to match the path and headers of a http request.
func NewRequest ¶
func NewRequestFromMap ¶ added in v2.6.0
NewRequestFromMap creates a new Request based on the values of the given map. Aside from http headers, the map may contain one of three special keys.
:path-equal: path will match if equal to the value :path-prefix: path will match prefixed by the value :path-regex: path will match it matches the regexp value
type Value ¶
type Value interface { fmt.Stringer // Matches returns true if the given string matches this Value Matches(value string) bool // Op returns either ==, =~, or prefix Op() string }
Value comes in three flavors. One that performs an exact match against a string, one that uses a regular expression, and one that uses prefix matching.