move server/* to scnserver/*
This commit is contained in:
31
scnserver/api/ginext/gin.go
Normal file
31
scnserver/api/ginext/gin.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package ginext
|
||||
|
||||
import (
|
||||
scn "blackforestbytes.com/simplecloudnotifier"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var SuppressGinLogs = false
|
||||
|
||||
func NewEngine(cfg scn.Config) *gin.Engine {
|
||||
engine := gin.New()
|
||||
|
||||
engine.RedirectFixedPath = false
|
||||
engine.RedirectTrailingSlash = false
|
||||
|
||||
if cfg.Cors {
|
||||
engine.Use(CorsMiddleware())
|
||||
}
|
||||
|
||||
if cfg.GinDebug {
|
||||
ginlogger := gin.Logger()
|
||||
engine.Use(func(context *gin.Context) {
|
||||
if SuppressGinLogs {
|
||||
return
|
||||
}
|
||||
ginlogger(context)
|
||||
})
|
||||
}
|
||||
|
||||
return engine
|
||||
}
|
||||
Reference in New Issue
Block a user