提交 38b50068 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

init 3.0 server

上级 c190a4ab
Version = 2.2
Version = 2.2
Language = zh
......@@ -45,6 +45,7 @@ func main() {
flagSet.StringVar(&vari.Ip, "bind", "", "")
flagSet.IntVar(&vari.Port, "p", 0, "")
flagSet.IntVar(&vari.Port, "port", 0, "")
flagSet.BoolVar(&vari.Verbose, "verbose", false, "")
configUtils.InitConfig(root)
vari.DB, _ = serverConfig.NewGormDB()
......@@ -56,6 +57,7 @@ func main() {
os.Exit(1)
}
startAdminServer()
startDataServer()
}
......
......@@ -8,6 +8,8 @@ require (
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.2
github.com/Chain-Zhang/pinyin v0.1.3
github.com/Knetic/govaluate v3.0.0+incompatible
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible // indirect
github.com/dzwvip/oracle v1.2.1
github.com/elazarl/go-bindata-assetfs v1.0.1
github.com/emirpasic/gods v1.12.0
......@@ -18,28 +20,27 @@ require (
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
github.com/fatih/color v1.13.0
github.com/golang/protobuf v1.5.2
github.com/gopherjs/gopherjs v0.0.0-20210202160940-bed99a852dfe // indirect
github.com/iris-contrib/middleware/cors v0.0.0-20220417122231-60b1fdb1e02b // indirect
github.com/jinzhu/copier v0.2.5
github.com/kataras/iris/v12 v12.2.0-alpha3
github.com/kataras/iris/v12 v12.2.0-alpha9
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-runewidth v0.0.10
github.com/mattn/go-sqlite3 v1.14.12
github.com/mholt/archiver/v3 v3.5.0
github.com/nats-io/jwt v0.3.2 // indirect
github.com/oklog/ulid/v2 v2.0.2
github.com/pierrec/lz4/v4 v4.1.3 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/robfig/cron/v3 v3.0.1
github.com/satori/go.uuid v1.2.0
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/smartystreets/assertions v1.2.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/snowlyg/helper v0.0.6 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/xuri/efp v0.0.0-20210128032744-13be4fd5dcb5 // indirect
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.63.0
gopkg.in/ini.v1 v1.66.4
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
gorm.io/driver/mysql v1.3.3
......
此差异已折叠。
package middleware
import (
"github.com/iris-contrib/middleware/cors"
"github.com/kataras/iris/v12/context"
)
// CrsAuth 跨域中间件
func CrsAuth() context.Handler {
return cors.New(cors.Options{
AllowedOrigins: []string{"*"}, // allows everything, use that to change the hosts.
AllowedMethods: []string{"PUT", "PATCH", "GET", "POST", "OPTIONS", "DELETE"},
AllowedHeaders: []string{"*"},
ExposedHeaders: []string{"Accept", "Content-Type", "Content-Length", "Accept-Encoding", "X-CSRF-Token", "Authorization"},
AllowCredentials: true,
})
}
package middleware
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/context"
)
func InitCheck() iris.Handler {
return func(ctx *context.Context) {
//lang := ctx.URLParam("lang")
//if lang != commConsts.Language {
// commConsts.Language = lang
// i118Utils.Init(commConsts.Language, commConsts.AppServer)
//}
ctx.Next()
}
}
......@@ -35,7 +35,13 @@ type WebServer struct {
// Init 初始化web服务
func Init(port int) *WebServer {
app := iris.New()
app.Logger().SetLevel("debug")
level := "info"
if vari.Verbose {
level = "debug"
}
app.Logger().SetLevel(level)
idleConnClosed := make(chan struct{})
iris.RegisterOnInterrupt(func() { //优雅退出
timeout := 10 * time.Second
......
......@@ -2,10 +2,9 @@ package web
import (
"fmt"
logUtils "github.com/easysoft/zentaoatf/internal/pkg/lib/log"
serverConfig "github.com/easysoft/zentaoatf/internal/server/config"
"github.com/easysoft/zentaoatf/internal/server/core/module"
"github.com/easysoft/zentaoatf/internal/server/middleware"
"github.com/easysoft/zendata/internal/server/core/middleware"
"github.com/easysoft/zendata/internal/server/core/module"
"github.com/easysoft/zendata/pkg/utils/vari"
"strings"
"github.com/kataras/iris/v12"
......@@ -22,10 +21,12 @@ func (webServer *WebServer) InitRouter() error {
app := webServer.app.Party("/").AllowMethods(iris.MethodOptions)
{
app.Use(middleware.InitCheck())
if serverConfig.CONFIG.System.Level == "debug" {
if vari.Verbose {
debug := DebugParty()
app.PartyFunc(debug.RelativePath, debug.Handler)
}
webServer.initModule()
webServer.AddUploadStatic()
webServer.AddWebStatic("/")
......@@ -34,8 +35,6 @@ func (webServer *WebServer) InitRouter() error {
return fmt.Errorf("build router %w", err)
}
serverConfig.PermRoutes = webServer.GetSources()
return nil
}
}
......@@ -45,10 +44,6 @@ func (webServer *WebServer) GetSources() []map[string]string {
routeLen := len(webServer.app.GetRoutes())
ch := make(chan map[string]string, routeLen)
for _, r := range webServer.app.GetRoutes() {
if strings.Index(r.Path, "test123") > -1 {
logUtils.Info("")
}
r := r
// 去除非接口路径
handerNames := context.HandlersNames(r.Handlers)
......
......@@ -25,5 +25,5 @@ func (m *DefModule) Party() module.WebModule {
index.Post("/sync", m.DefCtrl.Create).Name = "同步"
}
return module.NewModule("/sites", handler)
return module.NewModule("/defs", handler)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册