http.Request 部署到应用引擎时有未定义的字段

http.Request has undefined fields when deploying to appengine

我正在开发一个网络应用程序,我依赖于以下代码进行身份验证(我正在使用 github.com/dgrijalva/jwt-go 包):

func ValidateProtectedPage(protectedPage http.HandlerFunc) http.HandlerFunc {
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
    // If no Auth cookie is set then return a 404 not found
    cookie, err := req.Cookie("Auth")
    if err != nil {
        Forbidden(res)
        return
    }

    // Return a Token using the cookie
    token, err := jwt.ParseWithClaims(cookie.Value, &Claims{}, func(token *jwt.Token) (interface{}, error) {
        // Make sure token's signature wasn't changed
        if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
            return nil, fmt.Errorf("Unexpected siging method")
        }
        return []byte(util.Secret), nil
    })

    if err != nil {
        Forbidden(res)
        return
    }

    // Grab the tokens claims and pass it into the original request
    if claims, ok := token.Claims.(*Claims); ok && token.Valid {
        ctx := context.WithValue(req.Context(), "Auth", *claims)
        protectedPage(res, req.WithContext(ctx))
    } else {
        Forbidden(res)
    }
})}

问题是,我正在尝试将我的应用程序部署到 Appengine,但出现以下错误:

planilla-go/controllers/auth.go:45: req.Context undefined (type *http.Request has no field or method Context)
planilla-go/controllers/auth.go:46: req.WithContext undefined (type *http.Request has no field or method WithContext)

据我了解,这是由于 appengine 的请求与来自 go 库的请求之间的不兼容,但我还找不到解决方法

有没有办法包装或转换 http.Request 以改用 appengine?

Appengine 仅支持 Go 1.6。有点莫名其妙,因为它使我的应用程序在没有进行重大兼容性检修的情况下变得毫无用处,但这就是平台的当前状态