func (r *Request) Filter(fn FilterRequestFunc) *Request {
	r.Filters = append(r.Filters, fn)
	return r
}
Filter filters a new request filter function to filter http.Request before the matching process.
package gock
import (
	"encoding/base64"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
)
type MapRequestFunc func(*http.Request) *http.Request
type FilterRequestFunc func(*http.Request) bool
type Request struct {
	Mock Mock
	Response *Response
	Error error
	Counter int
	Persisted bool
	Options Options
	URLStruct *url.URL
	Method string
	CompressionScheme string
	Header http.Header
	Cookies []*http.Cookie
	PathParams map[string]string
	BodyBuffer []byte
	Mappers []MapRequestFunc
	Filters []FilterRequestFunc
}
func NewRequest() *Request {
	return &Request{
		Counter:    1,
		URLStruct:  &url.URL{},
		Header:     make(http.Header),
		PathParams: make(map[string]string),
	}
}
func (r *Request) URL(uri string) *Request {
	r.URLStruct, r.Error = url.Parse(uri)
	return r
}
func (r *Request) SetURL(u *url.URL) *Request {
	r.URLStruct = u
	return r
}
func (r *Request) Path(path string) *Request {
	r.URLStruct.Path = path
	return r
}
func (r *Request) Get(path string) *Request {
	return r.method("GET", path)
}
func (r *Request) Post(path string) *Request {
	return r.method("POST", path)
}
func (r *Request) Put(path string) *Request {
	return r.method("PUT", path)
}
func (r *Request) Delete(path string) *Request {
	return r.method("DELETE", path)
}
func (r *Request) Patch(path string) *Request {
	return r.method("PATCH", path)
}
func (r *Request) Head(path string) *Request {
	return r.method("HEAD", path)
}
func (r *Request) method(method, path string) *Request {
	if path != "/" {
		r.URLStruct.Path = path
	}
	r.Method = strings.ToUpper(method)
	return r
}
func (r *Request) Body(body io.Reader) *Request {
	r.BodyBuffer, r.Error = ioutil.ReadAll(body)
	return r
}
func (r *Request) BodyString(body string) *Request {
	r.BodyBuffer = []byte(body)
	return r
}
func (r *Request) File(path string) *Request {
	r.BodyBuffer, r.Error = ioutil.ReadFile(path)
	return r
}
func (r *Request) Compression(scheme string) *Request {
	r.Header.Set("Content-Encoding", scheme)
	r.CompressionScheme = scheme
	return r
}
func (r *Request) JSON(data interface{}) *Request {
	if r.Header.Get("Content-Type") == "" {
		r.Header.Set("Content-Type", "application/json")
	}
	r.BodyBuffer, r.Error = readAndDecode(data, "json")
	return r
}
func (r *Request) XML(data interface{}) *Request {
	if r.Header.Get("Content-Type") == "" {
		r.Header.Set("Content-Type", "application/xml")
	}
	r.BodyBuffer, r.Error = readAndDecode(data, "xml")
	return r
}
func (r *Request) MatchType(kind string) *Request {
	mime := BodyTypeAliases[kind]
	if mime != "" {
		kind = mime
	}
	r.Header.Set("Content-Type", kind)
	return r
}
func (r *Request) BasicAuth(username, password string) *Request {
	r.Header.Set("Authorization", "Basic "+basicAuth(username, password))
	return r
}
func (r *Request) MatchHeader(key, value string) *Request {
	r.Header[key] = []string{value}
	return r
}
func (r *Request) HeaderPresent(key string) *Request {
	r.Header[key] = []string{".*"}
	return r
}
func (r *Request) MatchHeaders(headers map[string]string) *Request {
	for key, value := range headers {
		r.Header[key] = []string{value}
	}
	return r
}
func (r *Request) MatchParam(key, value string) *Request {
	query := r.URLStruct.Query()
	query.Set(key, value)
	r.URLStruct.RawQuery = query.Encode()
	return r
}
func (r *Request) MatchParams(params map[string]string) *Request {
	query := r.URLStruct.Query()
	for key, value := range params {
		query.Set(key, value)
	}
	r.URLStruct.RawQuery = query.Encode()
	return r
}
func (r *Request) ParamPresent(key string) *Request {
	r.MatchParam(key, ".*")
	return r
}
func (r *Request) PathParam(key, val string) *Request {
	r.PathParams[key] = val
	return r
}
func (r *Request) Persist() *Request {
	r.Persisted = true
	return r
}
func (r *Request) WithOptions(options Options) *Request {
	r.Options = options
	return r
}
func (r *Request) Times(num int) *Request {
	r.Counter = num
	return r
}
func (r *Request) AddMatcher(fn MatchFunc) *Request {
	r.Mock.AddMatcher(fn)
	return r
}
func (r *Request) SetMatcher(matcher Matcher) *Request {
	r.Mock.SetMatcher(matcher)
	return r
}
func (r *Request) Map(fn MapRequestFunc) *Request {
	r.Mappers = append(r.Mappers, fn)
	return r
}