2024-01-20 01:27:10 +02:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
2024-01-22 00:36:05 +02:00
|
|
|
"github.com/JustKato/drive-health/lib/config"
|
2024-01-20 01:27:10 +02:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func SetupRouter() *gin.Engine {
|
2024-01-21 18:40:40 +02:00
|
|
|
cfg := config.GetConfiguration()
|
2024-01-20 01:27:10 +02:00
|
|
|
|
2024-01-21 22:56:53 +02:00
|
|
|
if !cfg.DebugMode {
|
|
|
|
// Set gin to release
|
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the Gin engine
|
|
|
|
r := gin.Default()
|
2024-01-21 22:50:50 +02:00
|
|
|
|
2024-01-21 18:40:40 +02:00
|
|
|
r.Use(BasicAuthMiddleware(cfg.IdentityUsername, cfg.IdentityPassword))
|
|
|
|
|
2024-01-20 01:27:10 +02:00
|
|
|
// Setup Health Pings
|
|
|
|
setupHealth(r)
|
|
|
|
// Setup Api
|
|
|
|
setupApi(r)
|
|
|
|
// Setup Frontend
|
|
|
|
setupFrontend(r)
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|