master v1.0.13
李光春 2 years ago
parent c4331869fa
commit af5cd686ff

4
.gitignore vendored

@ -4,5 +4,5 @@
.idea .idea
.vscode .vscode
*.log *.log
gitmod.sh *_test.go
*_test.go gomod.sh

@ -15,7 +15,7 @@ import (
"time" "time"
) )
const Version = "1.0.12" const Version = "1.0.13"
// Response 返回内容 // Response 返回内容
type Response struct { type Response struct {
@ -32,6 +32,7 @@ type Response struct {
ResponseTime time.Time //【返回】时间 ResponseTime time.Time //【返回】时间
} }
// App 实例
type App struct { type App struct {
Uri string // 全局请求地址没有设置url才会使用 Uri string // 全局请求地址没有设置url才会使用
Error error // 错误 Error error // 错误
@ -45,6 +46,7 @@ type App struct {
p12Cert *tls.Certificate // p12证书内容 p12Cert *tls.Certificate // p12证书内容
} }
// 定义
var ( var (
httpParamsModeJson = "JSON" httpParamsModeJson = "JSON"
httpParamsModeXml = "XML" httpParamsModeXml = "XML"
@ -132,6 +134,7 @@ func (app *App) SetParams(params Params) {
} }
} }
// SetP12Cert 设置证书
func (app *App) SetP12Cert(content *tls.Certificate) { func (app *App) SetP12Cert(content *tls.Certificate) {
app.p12Cert = content app.p12Cert = content
} }

@ -2,8 +2,10 @@ package gorequest
import ( import (
"net/url" "net/url"
"strings"
) )
// ResponseUrlParse 返回参数
type ResponseUrlParse struct { type ResponseUrlParse struct {
Uri string `json:"uri"` // URI Uri string `json:"uri"` // URI
Urn string `json:"urn"` // URN Urn string `json:"urn"` // URN
@ -35,3 +37,11 @@ func UriParse(input string) (resp ResponseUrlParse) {
resp.Fragment = parse.Fragment resp.Fragment = parse.Fragment
return return
} }
// UriFilterExcludeQueryString 过滤掉url中的参数
func UriFilterExcludeQueryString(uri string) string {
URL, _ := url.Parse(uri)
clearUri := strings.ReplaceAll(uri, URL.RawQuery, "")
clearUri = strings.TrimRight(clearUri, "?")
return strings.TrimRight(clearUri, "/")
}

Loading…
Cancel
Save