Mike Schwörer
00d77e508d
see https://github.com/mattn/go-sqlite3/issues/274 see https://github.com/mattn/go-sqlite3/issues/209 see https://stackoverflow.com/questions/32479071/sqlite3-error-database-is-locked-in-golang
32 lines
500 B
Go
32 lines
500 B
Go
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
|
|
}
|