【问题标题】:AppEngine Endpoint - header dataAppEngine Endpoint - 标头数据
【发布时间】:2015-09-11 04:20:29
【问题描述】:

我正在使用 Google App Engine 的端点。如何获取内置 AppEngine 的标头,例如

X-AppEngine-Country
X-AppEngine-Region
X-AppEngine-City
X-AppEngine-CityLatLong

如果我使用Servlet,很容易获得

request.getHeader("...")

有什么帮助吗?

【问题讨论】:

    标签: google-app-engine google-cloud-endpoints


    【解决方案1】:

    我刚刚找到一个解决方案,在你的端点方法中添加一个 HttpServletRequest 参数,例如

    @ApiMethod
    public MyResponse getResponse( HttpServletRequest req, @Named("infoId") String infoId ) {
        // Use 'req' as you would in a servlet, e.g.
        String countryCode = req.getHeader("X-AppEngine-Country");
    }
    

    【讨论】:

    • 看起来不错,希望您在所需的超时期限过去后接受自己的答案!-)
    猜你喜欢
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2014-10-08
    • 1970-01-01
    相关资源
    最近更新 更多