Begin refactoring and improving the middleware

This commit is contained in:
Dane Everitt
2021-01-16 11:02:57 -08:00
parent c2cfaf44b5
commit f6669213e8
4 changed files with 248 additions and 66 deletions

View File

@@ -3,15 +3,17 @@ package router
import (
"github.com/apex/log"
"github.com/gin-gonic/gin"
"github.com/pterodactyl/wings/router/middleware"
)
// Configures the routing infrastructure for this daemon instance.
// Configure configures the routing infrastructure for this daemon instance.
func Configure() *gin.Engine {
gin.SetMode("release")
m := Middleware{}
router := gin.New()
router.Use(gin.Recovery(), m.ErrorHandler(), m.SetAccessControlHeaders())
router.Use(gin.Recovery())
router.Use(middleware.AttachRequestID(), middleware.CaptureErrors(), middleware.SetAccessControlHeaders())
// @todo log this into a different file so you can setup IP blocking for abusive requests and such.
// This should still dump requests in debug mode since it does help with understanding the request
// lifecycle and quickly seeing what was called leading to the logs. However, it isn't feasible to mix