1 Star 0 Fork 0

庞飞/multiapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
url.go 856 Bytes
一键复制 编辑 原始数据 按行查看 历史
庞飞 提交于 2023-10-08 10:22 . 调整
package simple
import "net/url"
type UrlBuilder struct {
u *url.URL
query url.Values
}
func ParseUrl(rawUrl string) *UrlBuilder {
ub := &UrlBuilder{}
ub.u, _ = url.Parse(rawUrl)
ub.query = ub.u.Query()
return ub
}
func (builder *UrlBuilder) AddQuery(name, value string) *UrlBuilder {
builder.query.Add(name, value)
return builder
}
func (builder *UrlBuilder) AddQueries(queries map[string]string) *UrlBuilder {
for name, value := range queries {
builder.AddQuery(name, value)
}
return builder
}
func (builder *UrlBuilder) GetQuery() url.Values {
return builder.query
}
func (builder *UrlBuilder) GetURL() *url.URL {
return builder.u
}
func (builder *UrlBuilder) Build() *url.URL {
builder.u.RawQuery = builder.query.Encode()
return builder.u
}
func (builder *UrlBuilder) BuildStr() string {
return builder.Build().String()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/pangxianfei/multiapp.git
git@gitee.com:pangxianfei/multiapp.git
pangxianfei
multiapp
multiapp
v1.1.5

搜索帮助