http

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete[T any](url string, opts ...*RequestOptions) (data T, err error)

func Get

func Get[T any](url string, opts ...*RequestOptions) (data T, err error)

func Patch

func Patch[T any](url string, opts ...*RequestOptions) (data T, err error)

func Post

func Post[T any](url string, opts ...*RequestOptions) (data T, err error)

func Put

func Put[T any](url string, opts ...*RequestOptions) (data T, err error)

func Request

func Request[T any](method, url string, opts ...*RequestOptions) (data T, err error)

func RequestCallback

func RequestCallback(method, url string, opts *RequestOptions, callback Callback) (err error)

Types

type Callback

type Callback func(resp Response) (err error)

type Client

type Client[T any] interface {
	Get(uri string, opts ...*RequestOptions) (data T, err error)
	Post(uri string, opts ...*RequestOptions) (data T, err error)
	Patch(uri string, opts ...*RequestOptions) (data T, err error)
	Put(uri string, opts ...*RequestOptions) (data T, err error)
	Delete(uri string, opts ...*RequestOptions) (data T, err error)
	Request(method, uri string, opts ...*RequestOptions) (data T, err error)
}

func NewClient

func NewClient[T any](opts ...*Options) Client[T]

type Options

type Options struct {
	BaseURL string
}

type RequestOptions

type RequestOptions struct {
	ExpectsJSON bool
	Header      http.Header
	Body        io.Reader
}

type Response

type Response *http.Response

Jump to

Keyboard shortcuts

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