Documentation ¶
Index ¶
- Constants
- func ClientIp(r *http.Request) string
- func DeCode(s string) string
- func GetCmdOutsideIP() string
- func GetInsideIp(ctx context.Context) string
- func GetMacAddr(ctx context.Context) (arrays []string)
- func GetOutsideIPV4All(ctx context.Context) string
- func GetOutsideIPV6All(ctx context.Context) string
- func GetOutsideIp(ctx context.Context) string
- func GetParamsString(src interface{}) string
- func GetRandomUserAgent() string
- func GetRandomUserAgentSystem() string
- func Ips(ctx context.Context) (map[string]string, error)
- func IsIPV4(s string) bool
- func IsIPV6(s string) bool
- func IsIPv4Public(ip net.IP) bool
- func IsIPv6Public(ip net.IP) bool
- func IsWechatMiniProgramRequest(r *http.Request, appid string) error
- func LenCode(s string) string
- func ParseQuery(s string) map[string][]string
- func ToXml(params map[string]interface{}) (reader io.Reader, err error)
- type App
- func (app *App) Get(ctx context.Context, uri ...string) (httpResponse Response, err error)
- func (app *App) Post(ctx context.Context, uri ...string) (httpResponse Response, err error)
- func (app *App) Request(ctx context.Context) (httpResponse Response, err error)
- func (app *App) SetAuthToken(token string)
- func (app *App) SetContentTypeForm()
- func (app *App) SetContentTypeJson()
- func (app *App) SetContentTypeXml()
- func (app *App) SetCookie(cookie string)
- func (app *App) SetDebug()
- func (app *App) SetHeader(key, value string)
- func (app *App) SetHeaders(headers Headers)
- func (app *App) SetMethod(method string)
- func (app *App) SetP12Cert(content *tls.Certificate)
- func (app *App) SetParam(key string, value interface{})
- func (app *App) SetParams(params Params)
- func (app *App) SetTlsVersion(minVersion, maxVersion uint16)
- func (app *App) SetUri(uri string)
- func (app *App) SetUserAgent(ua string)
- type Headers
- type Params
- type Response
- func (r *Response) HeaderHtml() bool
- func (r *Response) HeaderIsImg() bool
- func (r *Response) HeaderIsJpeg() bool
- func (r *Response) HeaderIsJpg() bool
- func (r *Response) HeaderIsPng() bool
- func (r *Response) HeaderJson() bool
- func (r *Response) HeaderTextHtml() bool
- func (r *Response) HeaderXHtml() bool
- type ResponseUrlParse
- type UriParse
Constants ¶
View Source
const Version = "1.0.51"
Variables ¶
This section is empty.
Functions ¶
func ClientIp ¶
ClientIp 尽最大努力实现获取客户端 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func GetMacAddr ¶ added in v1.0.40
GetMacAddr 获取Mac地址
func GetOutsideIPV4All ¶ added in v1.0.50
GetOutsideIPV4All 外网IPV4地址
func GetOutsideIPV6All ¶ added in v1.0.50
GetOutsideIPV6All 外网IPV6地址
func GetOutsideIp ¶ added in v1.0.40
GetOutsideIp 外网IP
func GetRandomUserAgentSystem ¶
func GetRandomUserAgentSystem() string
GetRandomUserAgentSystem 获取系统随机UA
func IsIPv4Public ¶ added in v1.0.50
func IsIPv6Public ¶ added in v1.0.50
func IsWechatMiniProgramRequest ¶ added in v1.0.39
IsWechatMiniProgramRequest 判断是否是微信小程序
func ParseQuery ¶ added in v1.0.19
ParseQuery 获取URL参数 https://studygolang.com/articles/2876
Types ¶
type App ¶
type App struct { Uri string // 全局请求地址,没有设置url才会使用 Error error // 错误 // contains filtered or unexported fields }
App 实例
func (*App) SetTlsVersion ¶ added in v1.0.39
SetTlsVersion 设置TLS版本
type Response ¶
type Response struct { RequestId string //【请求】编号 RequestUri string //【请求】链接 RequestParams Params //【请求】参数 RequestMethod string //【请求】方式 RequestHeader Headers //【请求】头部 RequestCookie string //【请求】Cookie RequestTime time.Time //【请求】时间 ResponseHeader http.Header //【返回】头部 ResponseStatus string //【返回】状态 ResponseStatusCode int //【返回】状态码 ResponseBody []byte //【返回】内容 ResponseContentLength int64 //【返回】大小 ResponseTime time.Time //【返回】时间 }
Response 返回内容
func (*Response) HeaderHtml ¶ added in v1.0.28
HeaderHtml 判断是否为Html
func (*Response) HeaderIsImg ¶ added in v1.0.28
HeaderIsImg 判断是否为图片
func (*Response) HeaderIsJpeg ¶ added in v1.0.28
HeaderIsJpeg 判断是否为jpeg图片
func (*Response) HeaderIsJpg ¶ added in v1.0.28
HeaderIsJpg 判断是否为Jpg图片
func (*Response) HeaderIsPng ¶ added in v1.0.28
HeaderIsPng 判断是否为Png图片
func (*Response) HeaderJson ¶ added in v1.0.28
HeaderJson 判断是否为Json数据
func (*Response) HeaderTextHtml ¶ added in v1.0.28
HeaderTextHtml 判断是否为Html
func (*Response) HeaderXHtml ¶ added in v1.0.28
HeaderXHtml 判断是否为Html
type ResponseUrlParse ¶
type ResponseUrlParse struct { Uri string `json:"uri"` // URI Urn string `json:"urn"` // URN Url string `json:"url"` // URL Scheme string `json:"scheme"` // 协议 Host string `json:"host"` // 主机 Hostname string `json:"hostname"` // 主机名 Port string `json:"port"` // 端口 Path string `json:"path"` // 路径 RawQuery string `json:"raw_query"` // 参数 ? Fragment string `json:"fragment"` // 片段 # }
ResponseUrlParse 返回参数
type UriParse ¶
type UriParse struct {
// contains filtered or unexported fields
}
func (*UriParse) Parse ¶ added in v1.0.29
func (u *UriParse) Parse() (resp ResponseUrlParse)
Parse 解析URl
func (*UriParse) UriFilterExcludeQueryString ¶ added in v1.0.29
UriFilterExcludeQueryString 过滤掉url中的参数
Click to show internal directories.
Click to hide internal directories.