request

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete[T any](c *Client, path string, opts ...Opt) (*T, error)

func Get

func Get[T any](c *Client, path string, opts ...Opt) (*T, error)

func GetHeaderMap

func GetHeaderMap(header string) map[string]string

func Post

func Post[T any](c *Client, path string, body any, opts ...Opt) (*T, error)

func Put

func Put[T any](c *Client, path string, body any, opts ...Opt) (*T, error)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(scheme string, host string, timeout time.Duration, opts ...ReqOpt) *Client

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool)

func (*Client) SetTransport

func (c *Client) SetTransport(tr *http.Transport)

type Ctx

type Ctx struct {
	// contains filtered or unexported fields
}
type Header map[string]string

type Opt

type Opt func(ctx *Ctx)

func WithBody

func WithBody(body any) Opt

func WithContentType

func WithContentType(contentType string) Opt

func WithHeader

func WithHeader(h Header) Opt

func WithQuery

func WithQuery(q Query) Opt

type Query

type Query map[string]string

type ReqOpt

type ReqOpt func(c *Client)

func WithClient

func WithClient(client *http.Client) ReqOpt

func WithDebug

func WithDebug() ReqOpt

func WithTransport

func WithTransport(tr *http.Transport) ReqOpt

type Response

type Response[T any] struct {
	Code    int    `json:"code"`
	Data    T      `json:"data"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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