mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-13 06:40:41 +00:00
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:
committed by
Benj Fassbind
parent
8e62195eb5
commit
c187b0d52c
@@ -52,3 +52,4 @@ List of contributors, in chronological order:
|
|||||||
* Steven Stone (https://github.com/smstone)
|
* Steven Stone (https://github.com/smstone)
|
||||||
* Josh Bayfield (https://github.com/jbayfield)
|
* Josh Bayfield (https://github.com/jbayfield)
|
||||||
* Boxjan (https://github.com/boxjan)
|
* Boxjan (https://github.com/boxjan)
|
||||||
|
* Mauro Regli (https://github.com/reglim)
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ func (s *ApiSuite) HTTPRequest(method string, url string, body io.Reader) (*http
|
|||||||
return w, nil
|
return w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ApiSuite) TestGinRunsInReleaseMode(c *C) {
|
||||||
|
c.Check(gin.Mode(), Equals, gin.ReleaseMode)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ApiSuite) TestGetVersion(c *C) {
|
func (s *ApiSuite) TestGetVersion(c *C) {
|
||||||
response, err := s.HTTPRequest("GET", "/api/version", nil)
|
response, err := s.HTTPRequest("GET", "/api/version", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
ctx "github.com/aptly-dev/aptly/context"
|
ctx "github.com/aptly-dev/aptly/context"
|
||||||
"github.com/aptly-dev/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -22,6 +23,12 @@ func apiMetricsGet() gin.HandlerFunc {
|
|||||||
|
|
||||||
// Router returns prebuilt with routes http.Handler
|
// Router returns prebuilt with routes http.Handler
|
||||||
func Router(c *ctx.AptlyContext) http.Handler {
|
func Router(c *ctx.AptlyContext) http.Handler {
|
||||||
|
if aptly.EnableDebug {
|
||||||
|
gin.SetMode(gin.DebugMode)
|
||||||
|
} else {
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
}
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
context = c
|
context = c
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user