Documentation
¶
Overview ¶
Package CachedHttpClient provides structs and a interface to add a custom cache to a http.client
Index ¶
- Variables
- func CopyResponse(response *http.Response) (*http.Response, error)
- func DumpRequest(req *http.Request, ignoreBody bool, dontIncludeAllHeaders bool) ([]byte, error)
- func NewJsonX509CertificateArrayArray(certs [][]*x509.Certificate) [][]*JsonX509Certificate
- func ToX509CertificateArray(certificates []*JsonX509Certificate) []*x509.Certificate
- func ToX509CertificateArrayArray(certificates [][]*JsonX509Certificate) [][]*x509.Certificate
- type CachedTransport
- type Cacher
- type FileCache
- type FileCacheEntry
- type JsonPublicKey
- type JsonResponse
- type JsonTlsConnectionState
- type JsonX509Certificate
- type MapCache
- type MapCacheOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultCachedTransport = &CachedTransport{ Cache: NewMapCache(), Fallback: http.DefaultTransport, ContinueRoundTripWithSetError: nil, }
View Source
var DefaultCashedClient = &http.Client{ Transport: DefaultCachedTransport, }
View Source
var NotInCacheError = errors.New("request not in the cache")
Functions ¶
func CopyResponse ¶
CopyResponse creates a light copy of the response and the body and reads the body of the input response into a buffer and places a ReaderCloser of the buffers content in both responses
func DumpRequest ¶
DumpRequest dumps the request to bytes using httputil.DumpRequest if includeAllHeaders httputil.DumpRequestOut is used
func NewJsonX509CertificateArrayArray ¶
func NewJsonX509CertificateArrayArray(certs [][]*x509.Certificate) [][]*JsonX509Certificate
func ToX509CertificateArray ¶
func ToX509CertificateArray(certificates []*JsonX509Certificate) []*x509.Certificate
func ToX509CertificateArrayArray ¶
func ToX509CertificateArrayArray(certificates [][]*JsonX509Certificate) [][]*x509.Certificate
Types ¶
type CachedTransport ¶
type CachedTransport struct {
Cache Cacher
Fallback http.RoundTripper
ContinueRoundTripWithSetError func(transport *CachedTransport, err error, request *http.Request, response *http.Response) bool
}
type FileCache ¶
type FileCache struct {
*MapCache
// contains filtered or unexported fields
}
func NewFileCache ¶
NewFileCache create a new FileCache overriding the cache file
func OpenFileCache ¶
OpenFileCache loaded the cache from an existing cache file
func OpenOrCreateFileCache ¶
OpenOrCreateFileCache open the existing cache file or creates a new
type FileCacheEntry ¶
type FileCacheEntry struct {
Request string
Response *JsonResponse
}
type JsonPublicKey ¶
type JsonResponse ¶
type JsonResponse struct {
Status string
StatusCode int
Proto string
ProtoMajor int
ProtoMinor int
Header http.Header
Body []byte
ContentLength int64
TransferEncoding []string
Close bool
Uncompressed bool
Trailer http.Header
Request string
TLS *JsonTlsConnectionState
}
func NewJsonResponse ¶
func NewJsonResponse(res *http.Response) (*JsonResponse, error)
func (*JsonResponse) ToResponse ¶
func (response *JsonResponse) ToResponse() *http.Response
type JsonTlsConnectionState ¶
type JsonTlsConnectionState struct {
Version uint16
HandshakeComplete bool
DidResume bool
CipherSuite uint16
NegotiatedProtocol string
NegotiatedProtocolIsMutual bool
ServerName string
PeerCertificates []*JsonX509Certificate
VerifiedChains [][]*JsonX509Certificate
SignedCertificateTimestamps [][]byte
OCSPResponse []byte
TLSUnique []byte
}
func NewJsonTlsConnectionState ¶
func NewJsonTlsConnectionState(tls *tls.ConnectionState) *JsonTlsConnectionState
func (*JsonTlsConnectionState) ToConnectionState ¶
func (state *JsonTlsConnectionState) ToConnectionState() *tls.ConnectionState
type JsonX509Certificate ¶
type JsonX509Certificate struct {
Raw []byte
RawTBSCertificate []byte
RawSubjectPublicKeyInfo []byte
RawSubject []byte
RawIssuer []byte
Signature []byte
SignatureAlgorithm x509.SignatureAlgorithm
PublicKeyAlgorithm x509.PublicKeyAlgorithm
PublicKey *JsonPublicKey
Version int
SerialNumber *big.Int
Issuer pkix.Name
Subject pkix.Name
NotBefore, NotAfter time.Time
KeyUsage x509.KeyUsage
Extensions []pkix.Extension
ExtraExtensions []pkix.Extension
UnhandledCriticalExtensions []asn1.ObjectIdentifier
ExtKeyUsage []x509.ExtKeyUsage
UnknownExtKeyUsage []asn1.ObjectIdentifier
BasicConstraintsValid bool
IsCA bool
MaxPathLen int
MaxPathLenZero bool
SubjectKeyId []byte
AuthorityKeyId []byte
OCSPServer []string
IssuingCertificateURL []string
DNSNames []string
EmailAddresses []string
IPAddresses []net.IP
URIs []*url.URL
PermittedDNSDomainsCritical bool
PermittedDNSDomains []string
ExcludedDNSDomains []string
PermittedIPRanges []*net.IPNet
ExcludedIPRanges []*net.IPNet
PermittedEmailAddresses []string
ExcludedEmailAddresses []string
PermittedURIDomains []string
ExcludedURIDomains []string
CRLDistributionPoints []string
PolicyIdentifiers []asn1.ObjectIdentifier
}
func NewJsonX509Certificate ¶
func NewJsonX509Certificate(cert *x509.Certificate) *JsonX509Certificate
func NewJsonX509CertificateArray ¶
func NewJsonX509CertificateArray(certs []*x509.Certificate) []*JsonX509Certificate
func (*JsonX509Certificate) ToCertificate ¶
func (certificate *JsonX509Certificate) ToCertificate() *x509.Certificate
type MapCache ¶
type MapCache struct {
MapCacheOptions
// contains filtered or unexported fields
}
MapCache caches the response in a map string -> *http.Response
func NewMapCache ¶
func NewMapCache(options ...MapCacheOptions) *MapCache
type MapCacheOptions ¶
Click to show internal directories.
Click to hide internal directories.