Separate DEV_MODE (for assets + templates) and DEBUG (for logs + special routes)
This commit is contained in:
parent
a1dfbde52e
commit
138aad9bd9
3 changed files with 7 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
DEBUG=false
|
DEBUG=false
|
||||||
|
DEV_MODE=false
|
||||||
APP_LISTEN_ADDRESS=127.0.0.1
|
APP_LISTEN_ADDRESS=127.0.0.1
|
||||||
APP_LISTEN_PORT=3000
|
APP_LISTEN_PORT=3000
|
||||||
DATABASE_LOCATION=./people.db
|
DATABASE_LOCATION=./people.db
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Debug bool `env:"DEBUG"`
|
Debug bool `env:"DEBUG"`
|
||||||
|
DevMode bool `env:"DEV_MODE"`
|
||||||
App struct {
|
App struct {
|
||||||
ListenAddress string `env:"APP_LISTEN_ADDRESS"`
|
ListenAddress string `env:"APP_LISTEN_ADDRESS"`
|
||||||
ListenPort uint `env:"APP_LISTEN_PORT"`
|
ListenPort uint `env:"APP_LISTEN_PORT"`
|
||||||
|
|
|
||||||
5
main.go
5
main.go
|
|
@ -50,7 +50,7 @@ func main() {
|
||||||
|
|
||||||
// Create a new engine
|
// Create a new engine
|
||||||
var engine *django.Engine
|
var engine *django.Engine
|
||||||
if config.Debug {
|
if config.DevMode {
|
||||||
engine = django.New("./views", ".html")
|
engine = django.New("./views", ".html")
|
||||||
engine.ShouldReload = true
|
engine.ShouldReload = true
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -72,7 +72,7 @@ func main() {
|
||||||
ErrorHandler: helpers.FiberErrorHandler,
|
ErrorHandler: helpers.FiberErrorHandler,
|
||||||
})
|
})
|
||||||
|
|
||||||
if config.Debug {
|
if config.DevMode {
|
||||||
app.Static("/static", "./static")
|
app.Static("/static", "./static")
|
||||||
} else {
|
} else {
|
||||||
app.Use("/static", filesystem.New(filesystem.Config{
|
app.Use("/static", filesystem.New(filesystem.Config{
|
||||||
|
|
@ -101,6 +101,7 @@ func main() {
|
||||||
app.Use(middlewares.MfaVerifyMiddleware)
|
app.Use(middlewares.MfaVerifyMiddleware)
|
||||||
app.Use(middlewares.TemplatesMiddleware)
|
app.Use(middlewares.TemplatesMiddleware)
|
||||||
app.Use("/admin", middlewares.AuthzAdmin)
|
app.Use("/admin", middlewares.AuthzAdmin)
|
||||||
|
app.Use("/debug", middlewares.AuthzAdmin)
|
||||||
|
|
||||||
// Main pages
|
// Main pages
|
||||||
app.Get("/", controllers.Homepage)
|
app.Get("/", controllers.Homepage)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue