thttp

package
v1.0.54 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 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 added in v1.0.1

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

func Get added in v1.0.1

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

Get 根据path请求资源

func GetToMap added in v1.0.1

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

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

func GetToStruct added in v1.0.1

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

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

func PostForm added in v1.0.1

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

PostForm 以form格式请求

func PostJSON added in v1.0.1

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

PostJSON 以json格式请求

func PostJSONFromStruct added in v1.0.35

func PostJSONFromStruct(u string, obj interface{}, options ...Option) ([]byte, error)

func PostToMap added in v1.0.1

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

func PostToMapFromStruct added in v1.0.35

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

func PostToStruct added in v1.0.1

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

func PostToStructFromStruct added in v1.0.35

func PostToStructFromStruct[T any](u string, obj interface{}, options ...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 added in v1.0.1

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