【问题标题】:Get BasicAuth creds in Gin在 Gin 中获取 BasicAuth 凭据
【发布时间】:2017-03-14 23:50:59
【问题描述】:

我已经改用 Gin 来尝试一下。在移动之前,我使用如下请求对象访问了 BasicAuth 凭据(app_id 和令牌):

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 凭据。

【问题讨论】:

    标签: go basic-authentication go-gin


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2022-08-04
      • 1970-01-01
      • 2011-05-09
      • 2021-11-17
      • 2020-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      相关资源
      最近更新 更多