在使用”go tool pprof”通过fetch profile获取配置文件时,请指定jwt令牌。

huangapple go评论150阅读模式
英文:

Specify jwt token when fetch profile via "go tool pprof"

问题

我的 API 是通过 JWT 进行保护的,是否可以在使用 go tool pprof 获取个人资料时指定一个 JWT 令牌?

目前,我必须配置 JWT 中间件来绕过 /debug/pprof 路由。

英文:

My api is protected via jwt, is it possible to specify a jwt token when fetch profile via go tool pprof ?

Currently, I have to config jwt middleware to bypass the /debug/pprof routes.

答案1

得分: 2

我找不到直接通过go tool pprof传递令牌的方法,但由于你可以使用curl来获取配置文件,有一个简单的解决方法:

$ curl -o profile.out https://host/debug/pprof -H 'X-Authorization: $TOKEN'
$ go tool pprof profile.out
英文:

I couldn't find a way to pass a token via go tool pprof directly, but due to the fact that you can use curl to fetch the profile, there is a simple workaround:

$ curl -o profile.out https://host/debug/pprof -H 'X-Authorization: $TOKEN'
$ go tool pprof profile.out

huangapple
  • 本文由 发表于 2022年8月8日 19:44:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/73277356.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定