AppEngine 端点 - header 数据

AppEngine Endpoint - header data

我正在使用 Google App Engine 的端点。我怎样才能得到 built-in AppEngine 的 header 比如

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

如果我使用Servlet,很容易通过

获取
request.getHeader("...")

有什么帮助吗?

我刚找到一个解决方案,将 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");
}