diff --git a/server/internal/command/appcmd/appcmd.go b/server/internal/command/appcmd/appcmd.go index dbfe5af7..44ff25ef 100644 --- a/server/internal/command/appcmd/appcmd.go +++ b/server/internal/command/appcmd/appcmd.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/viper" ) -func SetupCommand(debug bool) *cobra.Command { +func SetupCommand() *cobra.Command { cmd := &cobra.Command{ Use: "app", Short: "Server Administration", @@ -27,7 +27,7 @@ func SetupCommand(debug bool) *cobra.Command { if err := storage.Create(context.Background(), db.Default, viper.GetString("default_storage_dir")); err != nil { logrus.Fatal(err) } - if err := core.Create(context.Background(), db.Default, storage.Default, debug); err != nil { + if err := core.Create(context.Background(), db.Default, storage.Default); err != nil { logrus.Fatal(err) } }, diff --git a/server/internal/command/appcmd/serve.go b/server/internal/command/appcmd/serve.go index 8832edaa..74dec2fd 100644 --- a/server/internal/command/appcmd/serve.go +++ b/server/internal/command/appcmd/serve.go @@ -23,7 +23,7 @@ func setupServeCommand() *cobra.Command { Short: "Run the server", Run: func(cmd *cobra.Command, args []string) { config := viper.GetViper() - engine := createEngine(config.GetBool("log_body"), config.GetBool("cors_enabled"), config.GetStringSlice("cors_origins")) + engine := createEngine(config.GetBool("debug"), config.GetBool("log_body"), config.GetBool("cors_enabled"), config.GetStringSlice("cors_origins")) engine.Use(errors.RecoverApiError) webdav.SetupHandler(engine.Group(config.GetString("webdav_prefix")), core.Default) @@ -60,8 +60,8 @@ func setupServeCommand() *cobra.Command { return cmdServe } -func createEngine(logBody bool, corsEnabled bool, corsOrigins []string) *gin.Engine { - if !core.Default.Debug { +func createEngine(debug, logBody bool, corsEnabled bool, corsOrigins []string) *gin.Engine { + if !debug { gin.SetMode(gin.ReleaseMode) } engine := gin.New() @@ -72,7 +72,7 @@ func createEngine(logBody bool, corsEnabled bool, corsOrigins []string) *gin.Eng "msg": "Internal Server Error", }) })) - if core.Default.Debug && logBody { + if debug && logBody { engine.Use(logBodyMiddleware) } diff --git a/server/internal/command/command.go b/server/internal/command/command.go index 834dba46..b6805586 100644 --- a/server/internal/command/command.go +++ b/server/internal/command/command.go @@ -12,8 +12,6 @@ import ( "github.com/spf13/viper" ) -var debug bool = false - func SetupCommand() { viper.SetEnvPrefix("phylum") @@ -39,7 +37,7 @@ func SetupCommand() { os.Mkdir(workDir, 0750) os.Chdir(workDir) } - debug = viper.GetBool("debug") + debug := viper.GetBool("debug") if debug { logrus.Info("Running in debug mode") logrus.SetLevel(logrus.TraceLevel) @@ -59,7 +57,7 @@ func SetupCommand() { }() rootCmd.AddCommand([]*cobra.Command{ - appcmd.SetupCommand(debug), + appcmd.SetupCommand(), setupSchemaCommand(), }...) rootCmd.Execute() diff --git a/server/internal/core/app.go b/server/internal/core/app.go index 638d92a0..dae570e3 100644 --- a/server/internal/core/app.go +++ b/server/internal/core/app.go @@ -14,7 +14,6 @@ const defaultUserUsername = "phylum" const defaultUserDisplayName = "Phylum" type App struct { - Debug bool Rootfs FileSystem db *db.DbHandler cs storage.Storage @@ -22,11 +21,10 @@ type App struct { var Default *App -func Create(ctx context.Context, db *db.DbHandler, cs storage.Storage, debug bool) error { +func Create(ctx context.Context, db *db.DbHandler, cs storage.Storage) error { Default = &App{ - Debug: debug, - db: db, - cs: cs, + db: db, + cs: cs, } return Default.setupAppData(ctx)