You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package main
import (
c "dsData/Controller"
"dsData/Handler"
"dsData/Middleware"
"dsData/Utils"
"dsData/Utils/ConfigUtil"
"dsData/Utils/FileUtil"
"fmt"
"github.com/gin-gonic/gin"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
//这个不导入会导致swagger的页面出错Failed to load spec
//http://www.freesion.com/article/3571182257/
_ "dsData/docs"
)
// @title 统一数据中心
// @version 1.0
// @description 由东师理想数智创新中心研发并提供支持
// @host 127.0.0.1:8003
func main() {
// 发布模式
//gin.SetMode(gin.ReleaseMode)
// 开发模式
gin.SetMode(gin.DebugMode)
// 开启gin服务器
r := gin.Default()
//启用日志中间件
r.Use(Middleware.LoggerToKafka())
// 使用跨域中间件
r.Use(Utils.Cors())
// 显示Logo
var logo = FileUtil.ReadFileContent("./Config/logo.txt")
fmt.Print(logo)
//注册swagger
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//注册权限拦截器
r.Use(Handler.AuthorizeHandler())
//主路由
c.GinRouter(r)
// 监听并在 0.0.0.0:8003 上启动服务
r.Run(":" + ConfigUtil.ServerPort)
}