【发布时间】:2023-02-20 16:35:25
【问题描述】:
我的 api 通过 jwt 保护,在通过 go tool pprof 获取配置文件时是否可以指定 jwt 令牌?
目前,我必须配置 jwt 中间件来绕过 /debug/pprof 路由。
【问题讨论】:
我的 api 通过 jwt 保护,在通过 go tool pprof 获取配置文件时是否可以指定 jwt 令牌?
目前,我必须配置 jwt 中间件来绕过 /debug/pprof 路由。
【问题讨论】:
我找不到直接通过 go tool pprof 传递令牌的方法,但由于您可以使用 curl 获取配置文件,因此有一个简单的解决方法:
$ curl -o profile.out https://host/debug/pprof -H 'X-Authorization: $TOKEN'
$ go tool pprof profile.out
【讨论】:
wget 的工作方式类似。
curl -o profile.out https://host/debug/pprof?seconds=5 -X 'X-Authorization: $TOKEN'
-H 标志的标头指定为 curl 而不是 -X。像这样:$ curl -o profile.out https://host/debug/pprof -H 'X-Authorization: $TOKEN'