mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-03 06:08:42 +00:00
Only enable debug endpoints if log level is debug or below (#1160)
This commit is contained in:
parent
d5cdd2bb04
commit
d8f598c2ad
1 changed files with 16 additions and 13 deletions
|
@ -16,6 +16,7 @@ package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/server/api"
|
"github.com/woodpecker-ci/woodpecker/server/api"
|
||||||
"github.com/woodpecker-ci/woodpecker/server/api/debug"
|
"github.com/woodpecker-ci/woodpecker/server/api/debug"
|
||||||
|
@ -155,19 +156,21 @@ func apiRoutes(e *gin.Engine) {
|
||||||
secrets.DELETE("/:secret", api.DeleteGlobalSecret)
|
secrets.DELETE("/:secret", api.DeleteGlobalSecret)
|
||||||
}
|
}
|
||||||
|
|
||||||
debugger := e.Group("/api/debug")
|
if zerolog.GlobalLevel() <= zerolog.DebugLevel {
|
||||||
{
|
debugger := e.Group("/api/debug")
|
||||||
debugger.Use(session.MustAdmin())
|
{
|
||||||
debugger.GET("/pprof/", debug.IndexHandler())
|
debugger.Use(session.MustAdmin())
|
||||||
debugger.GET("/pprof/heap", debug.HeapHandler())
|
debugger.GET("/pprof/", debug.IndexHandler())
|
||||||
debugger.GET("/pprof/goroutine", debug.GoroutineHandler())
|
debugger.GET("/pprof/heap", debug.HeapHandler())
|
||||||
debugger.GET("/pprof/block", debug.BlockHandler())
|
debugger.GET("/pprof/goroutine", debug.GoroutineHandler())
|
||||||
debugger.GET("/pprof/threadcreate", debug.ThreadCreateHandler())
|
debugger.GET("/pprof/block", debug.BlockHandler())
|
||||||
debugger.GET("/pprof/cmdline", debug.CmdlineHandler())
|
debugger.GET("/pprof/threadcreate", debug.ThreadCreateHandler())
|
||||||
debugger.GET("/pprof/profile", debug.ProfileHandler())
|
debugger.GET("/pprof/cmdline", debug.CmdlineHandler())
|
||||||
debugger.GET("/pprof/symbol", debug.SymbolHandler())
|
debugger.GET("/pprof/profile", debug.ProfileHandler())
|
||||||
debugger.POST("/pprof/symbol", debug.SymbolHandler())
|
debugger.GET("/pprof/symbol", debug.SymbolHandler())
|
||||||
debugger.GET("/pprof/trace", debug.TraceHandler())
|
debugger.POST("/pprof/symbol", debug.SymbolHandler())
|
||||||
|
debugger.GET("/pprof/trace", debug.TraceHandler())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logLevel := e.Group("/api/log-level")
|
logLevel := e.Group("/api/log-level")
|
||||||
|
|
Loading…
Reference in a new issue