Full refactor of codebase
This commit is contained in:
39
cmd/server/main.go
Normal file
39
cmd/server/main.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"strconv"
|
||||
|
||||
"github.com/ascyii/qrank/src/config"
|
||||
"github.com/ascyii/qrank/src/handlers"
|
||||
"github.com/ascyii/qrank/src/middleware"
|
||||
"github.com/ascyii/qrank/src/repository"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
|
||||
// Create engine
|
||||
if config.Config.Debug {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
} else {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
r := gin.Default()
|
||||
|
||||
// Setup the session store
|
||||
repository.SetupStore(r)
|
||||
|
||||
// Setup engine
|
||||
r.Use(middleware.SessionHandlerMiddleware())
|
||||
handlers.Register(r)
|
||||
r.Static("/assets", "./assets")
|
||||
|
||||
// Run the engine
|
||||
bind := ":" + strconv.Itoa(config.Config.AppPort)
|
||||
if err := r.Run(bind); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user