Fix: Switch gin mode depending on aptly.EnableDebug

If aptly.EnableDebug is active, we use Debug, otherwise we use
gin.ReleaseMode to remove the annoying nuding messages when running the
api.

fixes: #1103
This commit is contained in:
Mauro Regli authored and Benj Fassbind committed 2023-03-07 13:04:12 +01:00
1 parent 8e62195eb5
commit c187b0d52c
3 files changed
+12

No files matched your search

+7
View File
@@ -5,6 +5,7 @@ import (
"os"
"sync/atomic"
"github.com/aptly-dev/aptly/aptly"
ctx "github.com/aptly-dev/aptly/context"
"github.com/aptly-dev/aptly/utils"
"github.com/gin-gonic/gin"
@@ -22,6 +23,12 @@ func apiMetricsGet() gin.HandlerFunc {
// Router returns prebuilt with routes http.Handler
func Router(c *ctx.AptlyContext) http.Handler {
if aptly.EnableDebug {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
router := gin.New()
context = c