问题
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