1 Star 0 Fork 0

天雨流芳 / go-micro-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
endpoint.go 660 Bytes
一键复制 编辑 原始数据 按行查看 历史
天雨流芳 提交于 2024-03-19 15:24 . 增加通用文件
package endpoint
import (
"net/url"
)
// NewEndpoint new an Endpoint URL.
func NewEndpoint(scheme, host string) *url.URL {
return &url.URL{Scheme: scheme, Host: host}
}
// ParseEndpoint parses an Endpoint URL.
func ParseEndpoint(endpoints []string, scheme string) (string, error) {
for _, e := range endpoints {
u, err := url.Parse(e)
if err != nil {
return "", err
}
if u.Scheme == scheme {
return u.Host, nil
}
}
return "", nil
}
// Scheme is the scheme of endpoint url.
// examples: scheme="http",isSecure=true get "https"
func Scheme(scheme string, isSecure bool) string {
if isSecure {
return scheme + "s"
}
return scheme
}
1
https://gitee.com/tylf2018/go-micro-framework.git
git@gitee.com:tylf2018/go-micro-framework.git
tylf2018
go-micro-framework
go-micro-framework
e87e0c3d7074

搜索帮助