1 Star 0 Fork 0

llakcs / agile-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
target.go 577 Bytes
一键复制 编辑 原始数据 按行查看 历史
llakcs 提交于 2024-01-31 16:54 . 第一次提交
package target
import (
"net/url"
"strings"
)
type Target struct {
Scheme string
Authority string
Endpoint string
}
func ParseTarget(endpoint string, insecure, isGrpc bool) (*Target, error) {
if !isGrpc {
if !strings.Contains(endpoint, "://") {
if insecure {
endpoint = "http://" + endpoint
} else {
endpoint = "https://" + endpoint
}
}
}
u, err := url.Parse(endpoint)
if err != nil {
return nil, err
}
target := &Target{Scheme: u.Scheme, Authority: u.Host}
if len(u.Path) > 1 {
target.Endpoint = u.Path[1:]
}
return target, nil
}
1
https://gitee.com/llakcs/agile-go.git
git@gitee.com:llakcs/agile-go.git
llakcs
agile-go
agile-go
v1.2.0

搜索帮助