Documentation ¶
Overview ¶
Package messageview provides no-op snapshots for HTTP requests and responses.
Index ¶
- type MessageView
- func (mv *MessageView) BodyReader(opts ...Option) (io.ReadCloser, error)
- func (mv *MessageView) HeaderReader() io.Reader
- func (mv *MessageView) Reader(opts ...Option) (io.ReadCloser, error)
- func (mv *MessageView) SkipBody(skipBody bool)
- func (mv *MessageView) SkipBodyUnlessContentType(cts ...string)
- func (mv *MessageView) SnapshotRequest(req *http.Request) error
- func (mv *MessageView) SnapshotResponse(res *http.Response) error
- func (mv *MessageView) TrailerReader() io.Reader
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageView ¶
type MessageView struct {
// contains filtered or unexported fields
}
MessageView is a static view of an HTTP request or response.
func (*MessageView) BodyReader ¶
func (mv *MessageView) BodyReader(opts ...Option) (io.ReadCloser, error)
BodyReader returns an io.ReadCloser that reads the HTTP request or response body. If mv.skipBody was set the reader will immediately return io.EOF.
If the Decode option is passed the body will be unchunked if Transfer-Encoding is set to "chunked", and will decode the following Content-Encodings: gzip, deflate.
func (*MessageView) HeaderReader ¶
func (mv *MessageView) HeaderReader() io.Reader
HeaderReader returns an io.Reader that reads the HTTP Status-Line or HTTP Request-Line and headers.
func (*MessageView) Reader ¶
func (mv *MessageView) Reader(opts ...Option) (io.ReadCloser, error)
Reader returns the an io.ReadCloser that reads the full HTTP message.
func (*MessageView) SkipBody ¶
func (mv *MessageView) SkipBody(skipBody bool)
SkipBody will skip reading the body when the view is loaded with a request or response.
func (*MessageView) SkipBodyUnlessContentType ¶
func (mv *MessageView) SkipBodyUnlessContentType(cts ...string)
SkipBodyUnlessContentType will skip reading the body unless the Content-Type matches one in cts.
func (*MessageView) SnapshotRequest ¶
func (mv *MessageView) SnapshotRequest(req *http.Request) error
SnapshotRequest reads the request into the MessageView. If mv.skipBody is false it will also read the body into memory and replace the existing body with the in-memory copy. This method is semantically a no-op.
func (*MessageView) SnapshotResponse ¶
func (mv *MessageView) SnapshotResponse(res *http.Response) error
SnapshotResponse reads the response into the MessageView. If mv.headersOnly is false it will also read the body into memory and replace the existing body with the in-memory copy. This method is semantically a no-op.
func (*MessageView) TrailerReader ¶
func (mv *MessageView) TrailerReader() io.Reader
TrailerReader returns an io.Reader that reads the HTTP request or response trailers, if present.