httpc

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRespStatusCodeNotExpected = errors.New("response status code not expected")
)

Functions

func Connect added in v0.9.19

func Connect(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)

func Delete added in v0.9.19

func Delete(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)

func Do

func Do(ctx context.Context, timeout time.Duration, method string, url string, opts ...Option) (*http.Response, error)

func Get

func Get(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)
func Head(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)

func Options added in v0.9.19

func Options(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)

func Patch added in v0.9.19

func Patch(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)

func Post

func Post(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)

func Put

func Put(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)

func Trace added in v0.9.19

func Trace(ctx context.Context, timeout time.Duration, url string, opts ...Option) (*http.Response, error)

Types

type Option added in v0.9.19

type Option any

Option must implement reqOption or respOption.

func CheckStatusCode added in v0.9.19

func CheckStatusCode(statusCode ...int) Option

func ToAnyDecode added in v0.10.4

func ToAnyDecode(v any, newDecoder httpu.NewDecoder) Option

func ToAnyUnmarshal added in v0.9.19

func ToAnyUnmarshal(v any, unmarshaler func(bs []byte, v any) error) Option

func ToBytes added in v0.9.19

func ToBytes(n *int, b []byte) Option

func ToBytesBuffer added in v0.9.19

func ToBytesBuffer(n *int64, buf *bytes.Buffer) Option

func ToJSON added in v0.9.19

func ToJSON(v any) Option

func ToWriter added in v0.9.19

func ToWriter(n *int64, w io.Writer) Option

func WithBody added in v0.9.19

func WithBody(body []byte) Option

func WithBodyForm added in v0.9.19

func WithBodyForm(form url.Values) Option

func WithBodyJSON added in v0.9.19

func WithBodyJSON(v any) Option

func WithBodyMarshal added in v0.9.19

func WithBodyMarshal(v any, contentType string, marshal func(v any) ([]byte, error)) Option

func WithBodyReader added in v0.9.19

func WithBodyReader(reader io.Reader) Option

func WithHeaders added in v0.9.19

func WithHeaders(headerKvs ...string) Option

type ReqOptionFunc added in v0.9.19

type ReqOptionFunc func(r *http.Request) error

func (ReqOptionFunc) HandleReq added in v0.9.19

func (f ReqOptionFunc) HandleReq(r *http.Request) error

type RespOptionFunc added in v0.9.19

type RespOptionFunc func(r *http.Response) error

func (RespOptionFunc) HandleResp added in v0.9.19

func (f RespOptionFunc) HandleResp(r *http.Response) error

Jump to

Keyboard shortcuts

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