How to access the raw query string (or full URL) in a Chalice (AWS Lambda/API Gateway) app?

烈酒焚心 提交于 2021-02-19 06:01:34

问题


I'm using Chalice to build a fairly straightforward API on AWS Lambda & API Gateway.

I need a way to get access to the raw query string (i.e foo=bar&abc=123). When accessing the app.current_request.query_params dictionary, it's already been processed, such that any empty parameters (foo=&bar=) have been stripped out.

Unfortunately I'm working with a third-party API that sends a signed hash value in the query string, based off the raw query string. I can't verify it without the original, unaltered query string. Is there any way to access it other than current_request.query_params?


回答1:


If you wish to get everything you do the following.

Let's say you are hitting the route /objects/{what}?human=you&thing=computer

@app.route('/objects', methods=['GET'])
def myobject(what):
    everything = app.current_request.to_dict()
    print("look at me: {}".format(params))
    

For more information see: Request from the Chalice docs



来源:https://stackoverflow.com/questions/49635508/how-to-access-the-raw-query-string-or-full-url-in-a-chalice-aws-lambda-api-ga

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!