Documentation ¶
Index ¶
- func Dump(t *testing.T, w *http.Response, r *http.Request, opts ...Option)
- func Handler(t *testing.T, h http.Handler, opts ...Option) http.Handler
- func HandlerFunc(t *testing.T, h http.HandlerFunc, opts ...Option) http.Handler
- func Write(h *HTTP, pretty bool) ([]byte, error)
- type CompareMessageOption
- type CompareOption
- type Dumper
- type HTTP
- type Message
- type Option
- func Body(body bool) Option
- func CmpOpt(opt CompareOption) Option
- func Colors(colors bool) Option
- func Env(env string) Option
- func File(file string) Option
- func IgnoreRequestFields(val ...string) Option
- func IgnoreRequestHeaders(val ...string) Option
- func IgnoreResponseFields(val ...string) Option
- func IgnoreResponseHeaders(val ...string) Option
- func IndentJSON(indent bool) Option
- func MaskRequestFields(mask string, fields ...string) Option
- func MaskRequestHeaders(mask string, fields ...string) Option
- func MaskResponseFields(mask string, fields ...string) Option
- func MaskResponseHeaders(mask string, fields ...string) Option
- func Transformers(ts ...Transformer) Option
- type RoundTripper
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dump ¶
Dump is a function that takes a testing object, an HTTP response writer, an HTTP request, and a variadic list of options. It calls the Dumper's Dump method with these arguments.
func Handler ¶
Handler is a function that takes a testing object, an HTTP handler, and a variadic list of options. It returns an HTTP handler that is wrapped with the Dumper's Handler method.
func HandlerFunc ¶
HandlerFunc is similar to Handler, but it takes an HTTP handler function instead of an HTTP handler.
Types ¶
type CompareMessageOption ¶
func (CompareMessageOption) Merge ¶
func (c CompareMessageOption) Merge(o CompareMessageOption) CompareMessageOption
type CompareOption ¶
type CompareOption struct { Request CompareMessageOption Response CompareMessageOption }
func (CompareOption) Merge ¶
func (c CompareOption) Merge(o CompareOption) CompareOption
type Dumper ¶
type Dumper struct {
// contains filtered or unexported fields
}
Dumper is a struct that holds a slice of options.
func New ¶
New is a function that takes a variadic list of options and returns a new Dumper instance with these options.
func (*Dumper) Dump ¶
Dump is a method on the Dumper struct that takes a testing object, an HTTP response writer, an HTTP request, and a variadic list of options. It appends the options to the Dumper's options and then calls the Snapshot function with the testing object, a new HTTP instance, and the options.
func (*Dumper) Handler ¶
Handler is a method on the Dumper struct that takes a testing object, an HTTP handler, and a variadic list of options. It returns a new handler instance with these values.
func (*Dumper) HandlerFunc ¶
HandlerFunc is similar to Handler, but it takes an HTTP handler function instead of an HTTP handler.
type Message ¶
type Message struct { Line string `json:"line"` Header http.Header `json:"header"` Body any `json:"body"` Trailer http.Header `json:"trailer"` }
Message is a comparable representation of the request/response pair.
type Option ¶
type Option func(o *options)
Option is a type that defines a function that takes an options instance and modifies it.
func Body ¶
Body is a function that takes a bool and returns an options that writes the body to the file if true.
func CmpOpt ¶
func CmpOpt(opt CompareOption) Option
CmpOpt is a function that takes a CompareOption and returns an options that merges the CompareOption with the cmpOpt field of an options instance.
func Colors ¶
Colors is a function that takes a boolean and returns an options that sets the colors field of an options instance to the given boolean.
func Env ¶
Env is a function that takes a string and returns an options that sets the env field of an options instance to the given string.
func IgnoreRequestFields ¶
IgnoreRequestFields is similar to IgnoreRequestHeaders, but it appends the strings to the Request.Body field of the cmpOpt field of an options instance.
func IgnoreRequestHeaders ¶
IgnoreRequestHeaders is a function that takes a variadic list of strings and returns an options that appends the strings to the Request.Header field of the cmpOpt field of an options instance.
func IgnoreResponseFields ¶
IgnoreResponseFields is similar to IgnoreRequestFields, but it appends the strings to the Response.Body field of the cmpOpt field of an options instance.
func IgnoreResponseHeaders ¶
IgnoreResponseHeaders is similar to IgnoreRequestHeaders, but it appends the strings to the Response.Header field of the cmpOpt field of an options instance.
func IndentJSON ¶
IndentJSON is a function that takes a boolean and returns an options that sets the indentJSON field of an options instance to the given boolean.
func MaskRequestFields ¶
MaskRequestFields is similar to MaskRequestHeaders, but the new transformer masks the request fields.
func MaskRequestHeaders ¶
MaskRequestHeaders is a function that takes a mask string and a variadic list of fields and returns an options that appends a new transformer to the transformers field of an options instance. The new transformer masks the request headers specified by the fields with the mask string.
func MaskResponseFields ¶
MaskResponseFields is similar to MaskRequestFields, but the new transformer masks the response fields.
func MaskResponseHeaders ¶
MaskResponseHeaders is similar to MaskRequestHeaders, but the new transformer masks the response headers.
func Transformers ¶
func Transformers(ts ...Transformer) Option
Transformers is a function that takes a variadic list of transformers and returns an options that appends the transformers to the transformers field of an options instance.
type RoundTripper ¶
type RoundTripper struct {
// contains filtered or unexported fields
}
RoundTripper is a struct that holds a testing object and a slice of options.
func RoundTrip ¶
func RoundTrip(t *testing.T, opts ...Option) *RoundTripper
RoundTrip is a function that takes a testing object and a variadic list of options. It returns a new RoundTripper instance with these values.