client

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: Apache-2.0 Imports: 6 Imported by: 12

Documentation

Overview

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

Index

Constants

View Source
const Namespace = "github.com/starvn/turbo/transport/http/client"

Variables

View Source
var ErrInvalidStatusCode = errors.New("Invalid status code")

Functions

func DefaultHTTPStatusHandler

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

func ErrorHTTPStatusHandler

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

func NewHTTPClient

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

func NoOpHTTPStatusHandler

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

Types

type HTTPClientFactory

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

type HTTPRequestExecutor

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

func DefaultHTTPRequestExecutor

func DefaultHTTPRequestExecutor(clientFactory HTTPClientFactory) HTTPRequestExecutor

type HTTPResponseError

type HTTPResponseError struct {
	Code int    `json:"http_status_code"`
	Msg  string `json:"http_body,omitempty"`
}

func (HTTPResponseError) Error

func (r HTTPResponseError) Error() string

func (HTTPResponseError) StatusCode

func (r HTTPResponseError) StatusCode() int

type HTTPStatusHandler

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

func DetailedHTTPStatusHandler

func DetailedHTTPStatusHandler(name string) HTTPStatusHandler

func GetHTTPStatusHandler

func GetHTTPStatusHandler(remote *config.Backend) HTTPStatusHandler

type NamedHTTPResponseError

type NamedHTTPResponseError struct {
	HTTPResponseError
	// contains filtered or unexported fields
}

func (NamedHTTPResponseError) Name

func (r NamedHTTPResponseError) Name() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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