Documentation ¶
Index ¶
- Constants
- func Get(ctx context.Context, c *http.Client, url string) (*http.Response, error)
- func Head(ctx context.Context, c *http.Client, url string) (*http.Response, error)
- func NewHTTPClientWithDialFn(dialFn func(ctx context.Context) (net.Conn, error)) (*http.Client, error)
- func NewHTTPClientWithSocketPath(socketPath string) (*http.Client, error)
- func Post(ctx context.Context, c *http.Client, url string, body io.Reader) (*http.Response, error)
- func Successful(resp *http.Response) error
- type HTTPStatusError
Constants ¶
View Source
const HTTPStatusErrorBodyMaxLength = 64 * 1024
HTTPStatusErrorBodyMaxLength specifies the maximum length of HTTPStatusError.Body.
Variables ¶
This section is empty.
Functions ¶
func NewHTTPClientWithDialFn ¶ added in v0.21.0
func NewHTTPClientWithDialFn(dialFn func(ctx context.Context) (net.Conn, error)) (*http.Client, error)
NewHTTPClientWithDialFn creates a client. conn is a raw net.Conn instance.
func NewHTTPClientWithSocketPath ¶
NewHTTPClientWithSocketPath creates a client. socketPath is a path to the UNIX socket, without unix:// prefix.
func Successful ¶
Types ¶
type HTTPStatusError ¶
type HTTPStatusError struct { // StatusCode is non-2XX status code StatusCode int // Body is at most HTTPStatusErrorBodyMaxLength Body string }
HTTPStatusError is created from non-2XX HTTP response.
func (*HTTPStatusError) Error ¶
func (e *HTTPStatusError) Error() string
Error implements error. If e.Body is a marshalled string of httputil.ErrorJSON, Error returns ErrorJSON.Message . Otherwise Error returns a human-readable string that contains e.StatusCode and e.Body.
Click to show internal directories.
Click to hide internal directories.