https

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

RedirectCodes 有重定向含义的 http 响应码

Functions

func ClientRequestHost

func ClientRequestHost(c *gin.Context) string

ClientRequestHost 获取客户端请求的 Host

func ClientRequestUrl

func ClientRequestUrl(c *gin.Context) string

ClientRequestUrl 获取客户端请求的完整地址

func CloneHeader

func CloneHeader(c *gin.Context, header http.Header)

CloneHeader 克隆 http 头部到 gin 的响应头中

func ExtractReqBody added in v1.0.8

func ExtractReqBody(c *gin.Context) ([]byte, error)

ExtractReqBody 克隆并提取请求体 不影响 c 对象之后再次读取请求体

func IsErrorResponse

func IsErrorResponse(c *gin.Context) bool

IsErrorResponse 判断一个请求响应是否是错误响应

判断标准是响应码以 4xx 5xx 开头

func IsRedirectCode

func IsRedirectCode(code int) bool

IsRedirectCode 判断 http code 是否是重定向

301, 302, 307, 308

func MapBody

func MapBody(body map[string]interface{}) io.ReadCloser

MapBody 将 map 转换为 ReadCloser 流

func ProxyRequest

func ProxyRequest(c *gin.Context, remote string, withUri bool) error

ProxyRequest 代理请求

func Request

func Request(method, url string, header http.Header, body io.ReadCloser) (*http.Response, error)

Request 发起 http 请求获取响应

Types

This section is empty.

Jump to

Keyboard shortcuts

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