fix: Set whether to enable debug mode

This commit is contained in:
yv1ing
2024-12-19 15:44:12 +08:00
parent a068c22839
commit eee7943d2e
2 changed files with 8 additions and 2 deletions

View File

@@ -46,10 +46,16 @@ func init() {
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
} }
func (ma *MApp) Run() { func (ma *MApp) Run(debug bool) {
ma.loadRoutes() ma.loadRoutes()
ma.loadTemplates() ma.loadTemplates()
if debug {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
addr := fmt.Sprintf("%s:%d", ma.Host, ma.Port) addr := fmt.Sprintf("%s:%d", ma.Host, ma.Port)
log.Printf("app listening on %s\n", addr) log.Printf("app listening on %s\n", addr)
err := ma.engine.Run(addr) err := ma.engine.Run(addr)

View File

@@ -20,5 +20,5 @@ func init() {
func main() { func main() {
mapp := mApp.NewMApp(config.MConfigInstance) mapp := mApp.NewMApp(config.MConfigInstance)
mapp.Run() mapp.Run(true)
} }