Documentation
¶
Overview ¶
Example (Badgercache) ¶
Output: Request: 0 start cache miss response from server Response: Hello, 0 --- Request: 1 start Response: Hello, 0 --- Request: 2 start Response: Hello, 0 ---
Example (Rediscache) ¶
Output: Request: 0 start cache miss response from server Response: Hello, 0 --- Request: 1 start Response: Hello, 0 --- Request: 2 start Response: Hello, 0 ---
Example (Textcache) ¶
Output: Request: 0 start cache miss response from server Response: Hello, 0 --- Request: 1 start Response: Hello, 0 --- Request: 2 start Response: Hello, 0 ---
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
type Middleware interface {
RoundTripper(next http.RoundTripper) http.RoundTripper
}
type MiddlewareFunc ¶
type MiddlewareFunc func(next http.RoundTripper) http.RoundTripper
func DumpMiddleware ¶
func DumpMiddleware(w io.Writer) MiddlewareFunc
DumpMiddleware returns a MiddlewareFunc that logs HTTP requests and responses to the provided io.Writer.
func PrintMiddleware ¶
func PrintMiddleware(before, after string) MiddlewareFunc
PrintMiddleware returns a MiddlewareFunc that prints the specified strings before and after the HTTP request is processed by the next RoundTripper in the chain.
func (MiddlewareFunc) RoundTripper ¶
func (f MiddlewareFunc) RoundTripper(next http.RoundTripper) http.RoundTripper
type Option ¶
type Option func(*Transport)
Option is a functional option for configuring the CustomTransport.
func WithBaseTransport ¶
func WithBaseTransport(rt http.RoundTripper) Option
WithBaseTransport sets the base RoundTripper for the CustomTransport.
type RoundTripperFunc ¶
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
func NewTransport ¶
NewTransport creates a new instance of CustomTransport.
func (*Transport) RoundTrip ¶
RoundTrip executes a single HTTP transaction, as defined by http.RoundTripper.
func (*Transport) Use ¶
func (t *Transport) Use(middleware ...Middleware) *Transport
Use adds the provided middleware functions to the CustomTransport's middleware chain.
Click to show internal directories.
Click to hide internal directories.