gpt4 book ai didi

go - 在 Gin 中获取 BasicAuth 凭证

转载 作者:IT王子 更新时间:2023-10-29 02:05:02 25 4
gpt4 key购买 nike

我已经切换到 Gin 来尝试一下。在移动之前,我使用这样的请求对象访问了 BasicAuth 凭据(app_id 和 token ):

appId, token, _ := r.BasicAuth()

app_id 需要在每次调用时在我的数据库中找到,所以我为此使用了 Gin 中间件:

func CheckAppId() gin.HandlerFunc {
return func(c *gin.Context) {
//how do I access the BasicAuth creds here?
}
}

但我不确定如何在没有请求对象的情况下访问 BasicAuth 凭证。

最佳答案

gin 上下文包含 Request field. 中的 http.Request 对象

关于go - 在 Gin 中获取 BasicAuth 凭证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32463626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com