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.

76 lines
2.0 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 (
"dsBaseWeb/Handler"
"dsBaseWeb/Middleware"
"dsBaseWeb/Router"
"dsBaseWeb/Utils"
"dsBaseWeb/Utils/CommonUtil"
"dsBaseWeb/Utils/ConfigUtil"
"dsBaseWeb/Utils/FileUtil"
"fmt"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
//go get -u -v github.com/gin-gonic/gin
//go get -u github.com/swaggo/swag/cmd/swag
//go get -u -v github.com/swaggo/gin-swagger
//go get -u -v github.com/swaggo/gin-swagger/swaggerFiles
//这个不导入会导致swagger的页面出错Failed to load spec
//http://www.freesion.com/article/3571182257/
_ "dsBaseWeb/docs"
"github.com/gin-gonic/gin"
)
// @title 基础数据API
// @version 1.0
// @description 分布式,大并发,高可用
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host 127.0.0.1:8002
func main() {
// 发布模式
//gin.SetMode(gin.ReleaseMode)
// 开发模式
gin.SetMode(gin.DebugMode)
// 开启gin服务器
r := gin.Default()
//启用日志中间件
r.Use(Middleware.LoggerToKafka()) //debug级别日志
// 使用跨域中间件
r.Use(Utils.Cors())
// 注册后置拦截器,黄海添加于2020-05-19
r.Use(Middleware.AfterHandler())
// 显示Logo
configIniFile := "./Config/logo.txt"
if !CommonUtil.Exists(configIniFile) {
configIniFile = "/usr/local/dsMin/dsBaseWeb/Config/logo.txt"
}
var logo = FileUtil.ReadFileContent(configIniFile)
fmt.Print(logo)
//注册swagger
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//统一认证拦截器
r.Use(Handler.SsoHandler())
//EXCEL目录
//r.Static("/dsBaseWeb/static", "./Static")
//前台页面目录
r.Static("/dsBaseWeb", "./Html")
//参数有效性验证拦截器
r.Use(Handler.ParameterHandler())
//主路由
Router.GinRouter(r)
// 监听并在 0.0.0.0:8002 上启动服务
r.Run(":" + ConfigUtil.ServerPort)
}