在Google Cloud Endpoints中获取原始HTTP数据(标题,Cookie等) [英] Getting raw HTTP Data (Headers, Cookies, etc) in Google Cloud Endpoints
问题描述
我想知道是否可以在云端点收集原始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屋!