httptool

package
v0.0.0-...-2ac3d82 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildClient

func BuildClient(u, method string, q map[string]any, a ...any) (res *http.Client, req *http.Request, err error)

func Get

func Get(u string, q map[string]any, a ...any) (res *http.Response, err error)

func GetString

func GetString(u string, q map[string]any, a ...any) (r string, code int, err error)

func GetToJsonAny

func GetToJsonAny[T any](u string, q map[string]any, a ...any) (r T, code int, err error)

func Post

func Post(u string, types int, form map[string]any, a ...any) (res *http.Response, err error)

Post request

u url

types 1 x-www-form-urlencoded, 2 form-data, 3 json, 4 binary

func PostClient

func PostClient(u string, types int, form map[string]any, a ...any) (cli *http.Client, req *http.Request, err error)

func PostFormDataString

func PostFormDataString(u string, form map[string]any, a ...any) (r string, code int, err error)

func PostToJsonAny

func PostToJsonAny[T any](u string, types int, form map[string]any, a ...any) (r T, code int, err error)

func PostWwwString

func PostWwwString(u string, form map[string]any, a ...any) (r string, code int, err error)

func RequestToJSON

func RequestToJSON[T any](client *http.Client, req *http.Request, a ...any) (res *http.Response, r T, err error)

func SetArgs

func SetArgs(cli *http.Client, req *http.Request, a ...any)

func SetBody

func SetBody(req *http.Request, types int, form map[string]any) (err error)

SetBody types 1 x-www-form-urlencoded, 2 form-data, 3 json, 4 binary

func SetUrl

func SetUrl(u string, req *http.Request) error

Types

type BodyBuffer

type BodyBuffer struct {
	Offset  int
	Data    *[]byte
	ReadFn  func([]byte) (int, error)
	CloseFn func() error
}

func NewBodyBuffer

func NewBodyBuffer(byt *[]byte, readFn ...func(*BodyBuffer, []byte) (int, error)) *BodyBuffer

func (*BodyBuffer) Close

func (b *BodyBuffer) Close() error

func (*BodyBuffer) Read

func (b *BodyBuffer) Read(p []byte) (int, error)

func (*BodyBuffer) Reads

func (b *BodyBuffer) Reads(p []byte) (int, error)

Jump to

Keyboard shortcuts

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