1 Star 0 Fork 0

ichub / goconfig

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gateway_dto.go 1.62 KB
AI 代码解读
一键复制 编辑 原始数据 按行查看 历史
leijmdas 提交于 2024-05-05 12:24 . add
package baseconfig
import "gitee.com/ichub/goconfig/common/ichublog"
/*
@Title 文件名称: gateway_dto.go
@Description 描述: GatewayDto配置信息
@Author 作者: leijianming@163.com 时间(2024-02-18 22:38:21)
@Update 作者: leijianming@163.com 时间(2024-02-18 22:38:21)
*/
const SEVICE_NAME_NONE = "web.none.com"
// - path: /datadict
// serviceId: web.platform.com
type RouteDto struct {
ServiceId string `json:"service_id"`
Path string `json:"path"`
}
type BypassDto struct {
Path string `json:"path"`
}
type GatewayDto struct {
ByPass []BypassDto `json:"by_pass"`
Routes []RouteDto `json:"routes"`
//- path: /datadict
//serviceId: web.platform.com
MapPath2Service map[string]string
IchubClientDto `json:"-"`
}
func NewGatewayDto() *GatewayDto {
var dto = &GatewayDto{
MapPath2Service: map[string]string{},
}
dto.InitProxy(dto)
return dto
}
// - path: /datadict
// serviceId: web.platform.com
func (this *GatewayDto) ToMap() *GatewayDto {
if this.MapPath2Service == nil {
this.MapPath2Service = make(map[string]string)
}
for _, v := range this.Routes {
this.MapPath2Service[v.Path] = v.ServiceId
}
return this
}
func (this *GatewayDto) FindServiceName(path string) string {
//path: /datadict
//serviceId: web.platform.com
service, found := this.MapPath2Service[path]
if found {
ichublog.Log("find ServiceName byPath is ", service, path)
return service
}
ichublog.Log("find ServiceName byPath not found! ", path)
return SEVICE_NAME_NONE
}
func (this *GatewayDto) Bypass(path string) bool {
for _, v := range this.ByPass {
if v.Path == path {
return true
}
}
return false
}
1
https://gitee.com/ichub/goconfig.git
git@gitee.com:ichub/goconfig.git
ichub
goconfig
goconfig
v1.0.407

搜索帮助