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

前端 未结 2 1286
你的背包
你的背包 2020-11-29 06:27

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

2条回答
  •  醉酒成梦
    2020-11-29 07:08

    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();
        ...
    }
    

提交回复
热议问题