Add configuration for HTTP and debug mode

This commit is contained in:
eikendev 2020-07-31 20:04:33 +02:00
parent ba0306f384
commit 354ce0c08d
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694
4 changed files with 22 additions and 5 deletions

View file

@ -13,9 +13,13 @@ import (
)
// Create a Gin engine and setup all routes.
func Create(db *database.Database, dp *dispatcher.Dispatcher) *gin.Engine {
func Create(debug bool, db *database.Database, dp *dispatcher.Dispatcher) *gin.Engine {
log.Println("Setting up HTTP routes.")
if !debug {
gin.SetMode(gin.ReleaseMode)
}
auth := authentication.Authenticator{DB: db}
applicationHandler := api.ApplicationHandler{DB: db, Dispatcher: dp}
@ -23,6 +27,7 @@ func Create(db *database.Database, dp *dispatcher.Dispatcher) *gin.Engine {
userHandler := api.UserHandler{DB: db, Dispatcher: dp}
r := gin.Default()
r.Use(location.Default())
applicationGroup := r.Group("/application")