mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-19 20:26:26 +08:00
chore: standardize context keys with custom ContextKey type (#697)
* chore: standardize context keys with custom ContextKey type * fix bug * 使用Request.Context
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
_ "net/http/pprof"
|
||||
"runtime"
|
||||
|
||||
"github.com/OpenListTeam/OpenList/v4/internal/conf"
|
||||
"github.com/OpenListTeam/OpenList/v4/internal/sign"
|
||||
"github.com/OpenListTeam/OpenList/v4/server/common"
|
||||
"github.com/OpenListTeam/OpenList/v4/server/middlewares"
|
||||
@ -16,14 +17,14 @@ func _pprof(g *gin.RouterGroup) {
|
||||
}
|
||||
|
||||
func debug(g *gin.RouterGroup) {
|
||||
g.GET("/path/*path", middlewares.Down(sign.Verify), func(ctx *gin.Context) {
|
||||
rawPath := ctx.MustGet("path").(string)
|
||||
ctx.JSON(200, gin.H{
|
||||
g.GET("/path/*path", middlewares.Down(sign.Verify), func(c *gin.Context) {
|
||||
rawPath := c.Request.Context().Value(conf.PathKey).(string)
|
||||
c.JSON(200, gin.H{
|
||||
"path": rawPath,
|
||||
})
|
||||
})
|
||||
g.GET("/hide_privacy", func(ctx *gin.Context) {
|
||||
common.ErrorStrResp(ctx, "This is ip: 1.1.1.1", 400)
|
||||
g.GET("/hide_privacy", func(c *gin.Context) {
|
||||
common.ErrorStrResp(c, "This is ip: 1.1.1.1", 400)
|
||||
})
|
||||
g.GET("/gc", func(c *gin.Context) {
|
||||
runtime.GC()
|
||||
|
Reference in New Issue
Block a user