代码拉取完成,页面将自动刷新
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
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。