Documentation ¶
Overview ¶
Package cashttp implement HTTP cache based on CAS.
Index ¶
- type Header
- type Request
- type Response
- type Session
- type Transport
- func (t *Transport) MatchHeaders(list ...string)
- func (t *Transport) RequestFilter(fnc func(*http.Request) bool)
- func (t *Transport) ResponseFilter(fnc func(*http.Response) bool)
- func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)
- func (t *Transport) SetTransport(tr http.RoundTripper)
- type URL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
Header represents an HTTP header or trailer.
func (Header) MarshalJSON ¶
func (*Header) UnmarshalJSON ¶
type Request ¶
type Request struct { Method string `json:"method"` URL URL `json:"url"` Header Header `json:"header,omitempty"` Body types.SizedRef `json:"body,omitempty"` Trailer Header `json:"trailer,omitempty"` }
Request represents an HTTP request.
func (*Request) References ¶
type Response ¶
type Response struct { Status int `json:"status"` Header Header `json:"header,omitempty"` Body types.SizedRef `json:"body,omitempty"` Trailer Header `json:"trailer,omitempty"` }
Response represents an HTTP response.
func (*Response) References ¶
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
func NewTransport ¶
NewTransport creates an HTTP transport based on CAS that will store all the requests and responses and will replay them if request is sent again.
Requests will be matched against the cache based on exact URL match and on match of well-known headers (like Accept). See MatchHeaders for more details.
func (*Transport) MatchHeaders ¶
MatchHeaders adds additional headers that will be used to match requests versus cache entries.
func (*Transport) RequestFilter ¶
RequestFilter allows to ignore some requests so they are not stored in CAS. Caller should not inspect the body, or should replace it with a new copy.
func (*Transport) ResponseFilter ¶
ResponseFilter allows to ignore some responses so they are not stored in CAS. Caller should not inspect the body, or should replace it with a new copy.
func (*Transport) SetTransport ¶
func (t *Transport) SetTransport(tr http.RoundTripper)
SetTransport sets an underlying transport that is used to fill the cache.