client

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonResponse

func CommonResponse[RES any]() client.ResponseBodyCheck

func CommonResponse2

func CommonResponse2[RES any]() client.ResponseBodyCheck

func CommonResponse3

func CommonResponse3[RES any]() client.ResponseBodyCheck

func Delete

func Delete[RES any](url string, param any) (*RES, error)

func Get

func Get[RES any](url string, param any) (*RES, error)

func GetSubData

func GetSubData[RES ResponseInterface[T], T any](url string, param any) (T, error)

func GetWithOption

func GetWithOption[RES ResponseInterface[T], T any](url string, param any, options ...client.Option) (T, error)

func Post

func Post[RES any](url string, param any) (*RES, error)

func Put

func Put[RES any](url string, param any) (*RES, error)

Types

type Request

type Request[RES any] client.Request

func DeleteRequest

func DeleteRequest[RES any](url string) *Request[RES]

func GetRequest

func GetRequest[RES any](url string) *Request[RES]

func NewFromRequest

func NewFromRequest[RES any](req *client.Request) *Request[RES]

func NewRequest

func NewRequest[RES any](method, url string) *Request[RES]

func PostRequest

func PostRequest[RES any](url string) *Request[RES]

func PutRequest

func PutRequest[RES any](url string) *Request[RES]

func (*Request[RES]) Client

func (req *Request[RES]) Client() *client.Client

func (*Request[RES]) Do

func (r *Request[RES]) Do(param any) (*RES, error)

Do create a HTTP request

func (*Request[RES]) Origin

func (r *Request[RES]) Origin() *client.Request

func (*Request[RES]) SetClient

func (req *Request[RES]) SetClient(set func(c *client.Client)) *Request[RES]

func (*Request[RES]) WithClient

func (req *Request[RES]) WithClient(client2 *client.Client) *Request[RES]

type ResponseBody

type ResponseBody[RES any] httpi.ResData[RES]

func (*ResponseBody[RES]) CheckError

func (res *ResponseBody[RES]) CheckError() error

func (*ResponseBody[RES]) GetData

func (res *ResponseBody[RES]) GetData() *RES

type ResponseBody2

type ResponseBody2[RES any] struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data RES    `json:"data"`
}

func (*ResponseBody2[RES]) CheckError

func (res *ResponseBody2[RES]) CheckError() error

func (*ResponseBody2[RES]) GetData

func (res *ResponseBody2[RES]) GetData() *RES

type ResponseBody3

type ResponseBody3[RES any] struct {
	Status  int    `json:"status"`
	Data    RES    `json:"data"`
	Message string `json:"message"`
}

func (*ResponseBody3[RES]) CheckError

func (res *ResponseBody3[RES]) CheckError() error

type ResponseInterface

type ResponseInterface[T any] interface {
	client.ResponseBodyCheck
	SubData() T
}

type SubDataRequest

type SubDataRequest[RES ResponseInterface[T], T any] Request[RES]

一个语法糖,一般不用

func NewSubDataRequest

func NewSubDataRequest[RES ResponseInterface[T], T any](req *client.Request) *SubDataRequest[RES, T]

func (*SubDataRequest[RES, T]) Do

func (r *SubDataRequest[RES, T]) Do(param any) (T, error)

Do create a HTTP request

func (*SubDataRequest[RES, T]) Origin

func (req *SubDataRequest[RES, T]) Origin() *client.Request

func (*SubDataRequest[RES, T]) SubData

func (req *SubDataRequest[RES, T]) SubData(param any) (T, error)

Jump to

Keyboard shortcuts

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