Documentation ¶
Overview ¶
Package client provides some http helpers to create http clients and executors
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func DefaultHTTPStatusHandler(ctx context.Context, resp *http.Response) (*http.Response, error)
- func NewHTTPClient(ctx context.Context) *http.Client
- func NoOpHTTPStatusHandler(_ context.Context, resp *http.Response) (*http.Response, error)
- type HTTPClientFactory
- type HTTPRequestExecutor
- type HTTPResponseError
- type HTTPStatusHandler
Constants ¶
const Namespace = "github.com/devopsfaith/krakend/http"
Namespace to be used in extra config
Variables ¶
var ErrInvalidStatusCode = errors.New("Invalid status code")
ErrInvalidStatusCode is the error returned by the http proxy when the received status code is not a 200 nor a 201
Functions ¶
func DefaultHTTPStatusHandler ¶
DefaultHTTPStatusHandler is the default implementation of HTTPStatusHandler
func NewHTTPClient ¶
NewHTTPClient just returns the http default client
Types ¶
type HTTPClientFactory ¶
HTTPClientFactory creates http clients based with the received context
type HTTPRequestExecutor ¶
HTTPRequestExecutor defines the interface of the request executor for the HTTP transport protocol
func DefaultHTTPRequestExecutor ¶
func DefaultHTTPRequestExecutor(clientFactory HTTPClientFactory) HTTPRequestExecutor
DefaultHTTPRequestExecutor creates a HTTPRequestExecutor with the received HTTPClientFactory
type HTTPResponseError ¶
type HTTPResponseError struct { Code int `json:"http_status_code"` Msg string `json:"http_body,omitempty"` // contains filtered or unexported fields }
HTTPResponseError is the error to be returned by the DetailedHTTPStatusHandler
func (HTTPResponseError) Error ¶
func (r HTTPResponseError) Error() string
Error returns the error message
func (HTTPResponseError) Name ¶
func (r HTTPResponseError) Name() string
Name returns the name of the error
func (HTTPResponseError) StatusCode ¶
func (r HTTPResponseError) StatusCode() int
StatusCode returns the status code returned by the backend
type HTTPStatusHandler ¶
HTTPStatusHandler defines how we tread the http response code
func DetailedHTTPStatusHandler ¶
func DetailedHTTPStatusHandler(next HTTPStatusHandler, name string) HTTPStatusHandler
DetailedHTTPStatusHandler is a HTTPStatusHandler implementation
func GetHTTPStatusHandler ¶
func GetHTTPStatusHandler(remote *config.Backend) HTTPStatusHandler
GetHTTPStatusHandler returns a status handler. If the 'return_error_details' key is defined at the extra config, it returns a DetailedHTTPStatusHandler. Otherwise, it returns a DefaultHTTPStatusHandler