Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrJSONMarshal reports an error marshaling JSON. ErrJSONMarshal = errors.New("export: error marshaling JSON") // ErrFileCreate reports an error creating a file. ErrFileCreate = errors.New("export: error creating file") // ErrFileWrite reports an error writing a file. ErrFileWrite = errors.New("export: error writing file") // ErrHTTPRequest reports an error generating a HTTP request. ErrHTTPRequest = errors.New("export: request error") // ErrHTTPConnection reports an error sending a HTTP request. ErrHTTPConnection = errors.New("export: HTTP connection error") // ErrHTTPResponse reports a HTTP response error, such as bad status code. ErrHTTPResponse = &HTTPResponseError{} )
Functions ¶
func HTTP ¶
func HTTP(src HTTPRequester) error
HTTP sends the HTTP Request created by src and returns the first error occurring in the process. The error value can be:
- ErrHTTPRequest if it fails to create or send the request
- ErrHTTPResponse if the response returned a bad status code
- nil otherwise.
Types ¶
type HTTPRequester ¶
HTTPRequester interface expects a methods HTTPRequest returning a *http.Request to be sent in func HTTP.
type HTTPResponseError ¶ added in v1.0.0
type HTTPResponseError struct {
Code int
}
HTTPResponseError is an HTTP error due to a bad response code. It contains the received HTTP status code.
func (*HTTPResponseError) Error ¶ added in v1.0.0
func (e *HTTPResponseError) Error() string
Error implements error.
func (*HTTPResponseError) Is ¶ added in v1.0.0
func (e *HTTPResponseError) Is(err error) bool
Is returns true if err's type is HTTPResponseError. It allows comparison with ErrHTTPResponse using errors.Is:
errors.Is(&HTTPResponseError{}, ErrHTTPResponse) // true errors.Is(errors.New("any"), ErrHTTPResponse) // false
It does not perform check equality on the status code.
func (*HTTPResponseError) WithCode ¶ added in v1.0.0
func (e *HTTPResponseError) WithCode(code int) *HTTPResponseError
WithCode returns a *HTTPResponseError initialized with code.
type Interface ¶
type Interface interface { fmt.Stringer HTTPRequester }
Interface gathers the necessary methods to use any function exposed in this package.
Click to show internal directories.
Click to hide internal directories.