httpo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultErrorHandler

func DefaultErrorHandler(ctx context.Context, err error) (int, any)

func DefaultOkHandler

func DefaultOkHandler(ctx context.Context, data any) any

func NewService

func NewService(name string, opts ...httpc.Option) httpc.Service

func NewServiceWithClient

func NewServiceWithClient(name string, cli *http.Client, opts ...httpc.Option) httpc.Service

Types

type Client

type Client struct {
	Service httpc.Service
}

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, url string, data any) (*http.Response, error)

func (*Client) DoRequest

func (c *Client) DoRequest(r *http.Request) (*http.Response, error)

type CodeMsg

type CodeMsg struct {
	Code int
	Msg  string
}

CodeMsg 基础错误

func NewCodeMsg

func NewCodeMsg(code int, message string) *CodeMsg

func (*CodeMsg) Error

func (e *CodeMsg) Error() string

func (*CodeMsg) GetErrCode

func (e *CodeMsg) GetErrCode() int

func (*CodeMsg) GetErrMsg

func (e *CodeMsg) GetErrMsg() string

type Response

type Response struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data"`
}

Jump to

Keyboard shortcuts

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