Documentation
¶
Overview ¶
Package httpctx holds utilities for working with HTTP protocol.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrHTTPReqRes = errors.New("something wrong with HTTP(s) request/response")
ErrHTTPReqRes occurs when there is any problem with HTTP(s) req/res.
Functions ¶
This section is empty.
Types ¶
type HttpContext ¶
type HttpContext interface { // GetHTTPClient returns used *http.Client. GetHTTPClient() *http.Client // GetLastResponse returns last HTTP(s) response made by *http.Client. GetLastResponse() (*http.Response, error) // GetLastResponseBody returns bytes of last response body made by *http.Client. GetLastResponseBody() ([]byte, error) }
HttpContext describes entity that knows how to work with HTTP protocol.
type HttpService ¶
type HttpService struct {
// contains filtered or unexported fields
}
HttpService is entity that implements HttpContext interface.
func NewHttpService ¶ added in v0.8.6
func NewHttpService(c cache.Cache, cli *http.Client) HttpService
func (HttpService) GetHTTPClient ¶
func (h HttpService) GetHTTPClient() *http.Client
GetHTTPClient returns HTTP client.
func (HttpService) GetLastResponse ¶
func (h HttpService) GetLastResponse() (*http.Response, error)
GetLastResponse returns last HTTP(s) response.
func (HttpService) GetLastResponseBody ¶
func (h HttpService) GetLastResponseBody() ([]byte, error)
GetLastResponseBody returns last HTTP(s) response body. internally method creates new NoPCloser on last response so this method is safe to reuse many times
type URLValidator ¶ added in v0.8.6
type URLValidator struct{}
URLValidator has ability to validate URL
func NewURLValidator ¶ added in v0.8.6
func NewURLValidator() URLValidator
func (URLValidator) Validate ¶ added in v0.8.6
func (U URLValidator) Validate(in interface{}) error
Validate checks whether in is valid URL
Click to show internal directories.
Click to hide internal directories.