如何在Chalice(AWS Lambda/API Gateway)应用程序中访问原始查询字符串(或完整URL)? [英] How to access the raw query string (or full URL) in a Chalice (AWS Lambda/API Gateway) app?

查看:85
本文介绍了如何在Chalice(AWS Lambda/API Gateway)应用程序中访问原始查询字符串(或完整URL)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Chalice在AWS Lambda&上构建一个相当简单的API.API网关.

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

我需要一种访问原始查询字符串的方法(即 foo = bar& abc = 123 ).访问 app.current_request.query_params 字典时,已经对其进行了处理,因此已删除所有空参数( foo =& bar = ).

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.

不幸的是,我正在使用第三方API,它基于原始查询字符串在查询字符串中发送带符号的哈希值.没有原始的,未更改的查询字符串,我无法验证它.除了 current_request.query_params 之外,还有什么方法可以访问它?

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?

推荐答案

如果您希望获得一切,请执行以下操作.

If you wish to get everything you do the following.

比方说,您正在按路线/objects/{what}?human = you& thing = computer

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

这篇关于如何在Chalice(AWS Lambda/API Gateway)应用程序中访问原始查询字符串(或完整URL)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆