thttp

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddQuery

func AddQuery(rawUrl string, key string, value string) (string, error)

AddQuery url增加query参数

func Decompress

func Decompress(option Option, resp []byte) ([]byte, error)

func Get

func Get(u string, options ...Option) ([]byte, error)

Get 根据path请求资源

func GetToMap

func GetToMap(u string, options ...Option) (map[string]interface{}, error)

GetToMap 请求资源,以map形式返回结果

func GetToStruct

func GetToStruct[T any](u string, options ...Option) (T, error)

GetToStruct 请求资源,以struct形式返回结果

func PostForm

func PostForm(u string, form url.Values, options ...Option) ([]byte, error)

PostForm 以form格式请求

func PostJSON

func PostJSON(u string, jsonByte []byte, options ...Option) ([]byte, error)

PostJSON 以json格式请求

func PostToMap

func PostToMap(u string, jsonByte []byte, option ...Option) (map[string]interface{}, error)

func PostToStruct

func PostToStruct[T any](u string, jsonByte []byte, option ...Option) (T, error)

func QueryUrl

func QueryUrl(rawUrl string, key string) (string, error)

QueryUrl 查询url的query参数

func ResponseFail

func ResponseFail[T any](c *gin.Context, httpCode int, code int, msg string, data T)

func ResponseFailDefault

func ResponseFailDefault(c *gin.Context, msg string)

func ResponseSuccess

func ResponseSuccess[T any](c *gin.Context, code int, msg string, data T)

func ResponseSuccessDefault

func ResponseSuccessDefault[T any](c *gin.Context, data T)

Types

type Option

type Option struct {
	Decompress bool
	Header     map[string]string
}

Jump to

Keyboard shortcuts

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