Documentation ¶
Overview ¶
Package ghostport provides a http.RoundTripper for recording a number of recent requests/responses along with some other useful information for the purposes of diagnosting failures in applications that make a lot of http requests.
Index ¶
- Constants
- func NoopCensor(in []byte) []byte
- type Censor
- type Option
- type RoundTrip
- func (r RoundTrip) Duration() time.Duration
- func (r RoundTrip) End() time.Time
- func (r RoundTrip) Request() []byte
- func (r RoundTrip) RequestErr() error
- func (r RoundTrip) Response() []byte
- func (r RoundTrip) ResponseErr() error
- func (r RoundTrip) RoundTripErr() error
- func (r RoundTrip) Start() time.Time
- func (r RoundTrip) String() string
- type Transport
Constants ¶
const DefaultRingSize = 3
DefaultRingSize is 3 because that seems like a sensible number of requests to hang on to.
Variables ¶
This section is empty.
Functions ¶
func NoopCensor ¶
NoopCensor will simply do nothing but waste a couple of cpu cycles.
Types ¶
type Censor ¶
Censor funcs will let you filter input bytes to remove sensitive data before it's returned.
type Option ¶
type Option func(*Transport)
Option funcs allow the optional configuration of the Transport.
Generally you don't need to know or understand what this is, just look for the With* functions, for example: WithTransport.
func WithRequestCensor ¶
WithRequestCensor permits configuring a function to censor the output of requests before being returned.
func WithResponseCensor ¶
WithResponseCensor permits configuring a function to censor the output of responses before being returned.
func WithRingSize ¶
WithRingSize lets you specify the size of the ring buffer used to store the round trips, default is DefaultRingSize.
func WithTransport ¶
func WithTransport(transport http.RoundTripper) Option
WithTransport permits providing your own http.RoundTripper to be the underlying transport. If not used ghostport will use http.DefaultTransport.
type RoundTrip ¶
type RoundTrip struct {
// contains filtered or unexported fields
}
RoundTrip stores the request, response, errors associated with dumping them, any error returned by the underlying transport and the start end/time.
func (RoundTrip) RequestErr ¶
RequestErr will be nil unless there was an error dumping the request.
func (RoundTrip) ResponseErr ¶
ResponseErr will be nil unless there was an error dumping the response.
func (RoundTrip) RoundTripErr ¶
RoundTripErr will be nil unless there was an error returned by the underlying transport.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements the following interfaces; * http.RoundTripper to provide the ghostport. * fmt.Stringer so you can just print.
func (*Transport) RoundTrip ¶
RoundTrip fulfills the http.RoundTripper inteface and will record the time the trip starts, the time it ends, the request, and response from the underlying http.RoundTripper along with any errors it encounters along the way.