2 Star 4 Fork 5

联犀/中台模块

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
direct.go 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-10 21:56 . feat: 更新mod
package apidirect
import (
"gitee.com/unitedrhino/core/service/apisvr/internal/config"
"gitee.com/unitedrhino/core/service/apisvr/internal/handler"
"gitee.com/unitedrhino/core/service/apisvr/internal/handler/system/proxy"
"gitee.com/unitedrhino/core/service/apisvr/internal/startup"
"gitee.com/unitedrhino/core/service/apisvr/internal/svc"
"gitee.com/unitedrhino/core/service/datasvr/dataExport"
"gitee.com/unitedrhino/share/ctxs"
"gitee.com/unitedrhino/share/utils"
"github.com/zeromicro/go-zero/rest"
"net/http"
)
type (
Config = config.Config
ServiceContext = svc.ServiceContext
ApiCtx struct {
Server *rest.Server
SvcCtx *ServiceContext
}
)
var (
c config.Config
)
func NewApi(apiCtx ApiCtx) ApiCtx {
utils.ConfMustLoad("etc/api.yaml", &c)
apiCtx = runApi(apiCtx)
return apiCtx
}
func runApi(apiCtx ApiCtx) ApiCtx {
var server = apiCtx.Server
ctx := svc.NewServiceContext(c)
apiCtx.SvcCtx = ctx
if server == nil {
server = rest.MustNewServer(c.RestConf, rest.WithCustomCors(func(header http.Header) {
header.Set("Access-Control-Allow-Headers", ctxs.HttpAllowHeader)
header.Set("Access-Control-Allow-Origin", "*")
}, nil, "*"),
rest.WithNotFoundHandler(proxy.Handler(ctx)),
)
apiCtx.Server = server
}
handler.RegisterHandlers(server, ctx)
//handler.RegisterWsHandlers(apiCtx.SvcCtx.Ws, ctx)
startup.Init(ctx)
dataExport.Run(server)
return apiCtx
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/unitedrhino/core.git
git@gitee.com:unitedrhino/core.git
unitedrhino
core
中台模块
v1.2.1

搜索帮助