add url parse

master v1.0.7
李光春 2 years ago
parent 14c8375fa0
commit 4527cf0fae

@ -14,7 +14,7 @@ import (
"time"
)
const Version = "1.0.6"
const Version = "1.0.7"
// Response 返回内容
type Response struct {

@ -0,0 +1,29 @@
package gorequest
import (
"net/url"
)
type ResponseUrlParse struct {
Scheme string `json:"scheme"` // 协议
Hostname string `json:"hostname"` // 主机名
Port string `json:"port"` // 端口
Path string `json:"path"` // 路径
RawQuery string `json:"raw_query"` // 参数 ?
Fragment string `json:"fragment"` // 片段 #
}
// UrlParse 解析URl
func UrlParse(inputUrl string) (resp ResponseUrlParse) {
parse, err := url.Parse(inputUrl)
if err != nil {
return
}
resp.Scheme = parse.Scheme
resp.Hostname = parse.Hostname()
resp.Port = parse.Port()
resp.Path = parse.Path
resp.RawQuery = parse.RawQuery
resp.Fragment = parse.Fragment
return
}
Loading…
Cancel
Save