Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
2f398c73b3 | |
|
cb8e9bad4b |
|
@ -0,0 +1,18 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Cors() gin.HandlerFunc {
|
||||
return cors.New(cors.Config{
|
||||
AllowAllOrigins: true,
|
||||
AllowHeaders: []string{
|
||||
"Origin", "Content-Length", "Content-Type", "Workspace", "Request-Id", "Authorization", "Token",
|
||||
},
|
||||
AllowMethods: []string{
|
||||
"GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS",
|
||||
},
|
||||
})
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/env"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Mode(app *gin.Engine) {
|
||||
// 设置gin模式
|
||||
if env.Runtime.Mode == vars.RUN_MODE_PROD {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
} else {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ type LogItem struct {
|
|||
Level uint `json:"level"`
|
||||
Ip string `json:"ip"`
|
||||
Module string `json:"module"`
|
||||
Encry bool `json:"encry"`
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
Loading…
Reference in New Issue