package messageview
import "github.com/google/martian/v3/messageview"
Package messageview provides no-op snapshots for HTTP requests and responses.
Index ¶
- type MessageView
- func New() *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
Types ¶
type MessageView ¶
type MessageView struct {
// contains filtered or unexported fields
}
MessageView is a static view of an HTTP request or response.
func New ¶
func New() *MessageView
New returns a new MessageView.
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.
type Option ¶
type Option func(*config)
Option is a configuration option for a MessageView.
func Decode ¶
func Decode() Option
Decode sets an option to decode the message body for logging purposes.
Source Files ¶
- Version
- v3.3.3 (latest)
- Published
- Aug 16, 2022
- Platform
- darwin/amd64
- Imports
- 9 packages
- Last checked
- 4 hours ago –
Tools for package owners.