Help us shape the future of Go! Take the 2026 Go Developer Survey

httpclient

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedStatusCode = errors.New("unexpected status code").WithCode("UNEXPECTED_STATUS_CODE")

Functions

This section is empty.

Types

type Client

type Client interface {
	Patch(ctx context.Context, request *Request, opts ...RequestOption) (rst Result, err error)
	Put(ctx context.Context, request *Request, opts ...RequestOption) (rst Result, err error)
	Post(ctx context.Context, request *Request, opts ...RequestOption) (rst Result, err error)
	PostForm(ctx context.Context, request *Request, opts ...RequestOption) (rst Result, err error)
	Delete(ctx context.Context, request *Request, opts ...RequestOption) (rst Result, err error)
	Get(ctx context.Context, request *Request, opts ...RequestOption) (rst Result, err error)
}

func New

func New(opts ...Option) Client

type Headers

type Headers map[string]string

Headers is a map containing the relation key=value of the headers used on the http rest request.

type Option

type Option func(*client)

func WithTLSConfig

func WithTLSConfig(cfg *tls.Config) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type PathParams

type PathParams map[string]string

PathParams is a map containing the relation key=value of the path params used on the http rest request. It will be used to replace values given in Path parameter.

type QueryParams

type QueryParams map[string]string

QueryParams is a map containing the relation key=value of the query params used on the http rest request.

type Request

type Request struct {
	Host        string
	Path        string
	Body        []byte
	Headers     Headers
	QueryParams QueryParams
	PathParams  PathParams
	// contains filtered or unexported fields
}

Request are the params used to build a new http rest request.

type RequestOption

type RequestOption func(*Request)

func WithAcceptStatusCode

func WithAcceptStatusCode(code int) RequestOption

type Result

type Result struct {
	StatusCode int
	Response   []byte
}

Result are the params returned from the client HTTP request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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