Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting raw HTTP Data (Headers, Cookies, etc) in Google Cloud Endpoints

Tags:

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.

like image 269
bodega Avatar asked Feb 24 '13 21:02

bodega


1 Answers

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();
    ...
}
like image 73
Tom Avatar answered Nov 12 '22 19:11

Tom