v2.6.3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 40



Package client provides some http helpers to create http clients and executors



View Source
const Namespace = ""

Namespace to be used in extra config


View Source
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


func DefaultHTTPStatusHandler

func DefaultHTTPStatusHandler(_ context.Context, resp *http.Response) (*http.Response, error)

DefaultHTTPStatusHandler is the default implementation of HTTPStatusHandler

func ErrorHTTPStatusHandler

func ErrorHTTPStatusHandler(ctx context.Context, resp *http.Response) (*http.Response, error)

ErrorHTTPStatusHandler is a HTTPStatusHandler that returns the status code as part of the error details

func NewHTTPClient

func NewHTTPClient(_ context.Context) *http.Client

NewHTTPClient just returns the http default client

func NoOpHTTPStatusHandler

func NoOpHTTPStatusHandler(_ context.Context, resp *http.Response) (*http.Response, error)

NoOpHTTPStatusHandler is a NO-OP implementation of HTTPStatusHandler


type HTTPClientFactory

type HTTPClientFactory func(ctx context.Context) *http.Client

HTTPClientFactory creates http clients based with the received context

type HTTPRequestExecutor

type HTTPRequestExecutor func(ctx context.Context, req *http.Request) (*http.Response, error)

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"`
	Enc  string `json:"http_body_encoding,omitempty"`

HTTPResponseError is the error to be returned by the ErrorHTTPStatusHandler

func (HTTPResponseError) Encoding added in v2.6.0

func (r HTTPResponseError) Encoding() string

Encoding returns the content type returned by the backend

func (HTTPResponseError) Error

func (r HTTPResponseError) Error() string

Error returns the error message

func (HTTPResponseError) StatusCode

func (r HTTPResponseError) StatusCode() int

StatusCode returns the status code returned by the backend

type HTTPStatusHandler

type HTTPStatusHandler func(context.Context, *http.Response) (*http.Response, error)

HTTPStatusHandler defines how we tread the http response code

func DetailedHTTPStatusHandler

func DetailedHTTPStatusHandler(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

type NamedHTTPResponseError

type NamedHTTPResponseError struct {
	// contains filtered or unexported fields

NamedHTTPResponseError is the error to be returned by the DetailedHTTPStatusHandler

func (NamedHTTPResponseError) Name

func (r NamedHTTPResponseError) Name() string

Name returns the name of the backend where the error happened


Path Synopsis
Package graphql offers a param extractor and basic types for building GraphQL requests
Package graphql offers a param extractor and basic types for building GraphQL requests
Package plugin provides plugin register interfaces for building http client plugins.
Package plugin provides plugin register interfaces for building http client plugins.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL