升级server自动管理 #4
@ -10,6 +10,7 @@ package router
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
apiDoc "git.zhangdeman.cn/gateway/api-doc"
|
apiDoc "git.zhangdeman.cn/gateway/api-doc"
|
||||||
|
"git.zhangdeman.cn/zhangdeman/gin/middleware"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -26,8 +27,16 @@ func NewServer(port int, option any) *server {
|
|||||||
if port < 80 {
|
if port < 80 {
|
||||||
panic("port should be greater than 80")
|
panic("port should be greater than 80")
|
||||||
}
|
}
|
||||||
|
r := gin.Default()
|
||||||
|
r.Use(
|
||||||
|
// 初始化请求
|
||||||
|
middleware.InitRequest(),
|
||||||
|
/*request_cors.New(request_cors.Config{
|
||||||
|
AllowAllOrigins: true,
|
||||||
|
}), */// middleware.Ac
|
||||||
|
)
|
||||||
return &server{
|
return &server{
|
||||||
router: gin.Default(),
|
router: r,
|
||||||
uiInstance: apiDoc.NewSwaggerUI(nil, []*apiDocDefine.ServerItem{
|
uiInstance: apiDoc.NewSwaggerUI(nil, []*apiDocDefine.ServerItem{
|
||||||
{
|
{
|
||||||
Url: fmt.Sprintf("http://127.0.0.1:%d", port),
|
Url: fmt.Sprintf("http://127.0.0.1:%d", port),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user