在 Google Cloud Endpoints 中获取原始 HTTP 数据(标头、Cookie 等) [英] Getting raw HTTP Data (Headers, Cookies, etc) in Google Cloud Endpoints

查看:20
本文介绍了在 Google Cloud Endpoints 中获取原始 HTTP 数据(标头、Cookie 等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在 Cloud Endpoint 中收集原始 HTTP 数据.我似乎在 Google 的文档中找不到任何内容,但 App Engine 的 Twitter 告诉我它是 (https://twitter.com/app_engine/status/305747445017624576).如果是这样,我可以请它的语法吗?我知道 GCE 的 API 仍处于早期阶段,任何帮助将不胜感激.

I am wondering if it is possible to collect raw HTTP data in a Cloud Endpoint. I can't seem to find anything in Google's documentation, but App Engine's Twitter told me that it was (https://twitter.com/app_engine/status/305747445017624576). If so, can I please have syntax for it? I am aware that the API for GCE is still in its early stages, and any help would be greatly appreciated.

推荐答案

向端点方法添加 HttpServletRequest 参数,例如

Add an HttpServletRequest parameter to your endpoint method, e.g.

@ApiMethod
public MyResponse getResponse( HttpServletRequest req, @Named("infoId") String infoId ) {
    // Use 'req' as you would in a servlet, e.g.
    String ipAddress = req.getRemoteAddr();
    ...
}

这篇关于在 Google Cloud Endpoints 中获取原始 HTTP 数据(标头、Cookie 等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆