Simple AWS Lambda proxy to handle API Gateway request
Project description
A simple AWS Lambda proxy to handle API Gateway request
Install
$ pip install -U pip
$ pip install lambda-proxy
Or install from source:
$ git clone https://github.com/vincentsarag/lambda-proxy.git
$ cd lambda-proxy
$ pip install -U pip
$ pip install -e .
Usage
With GET request
>>> from lambda_proxy.proxy import API
>>> APP = API(app_name="app")
>>> @APP.route('/test/tests/<id>', methods=['GET'], cors=True)
>>> def print_id(id):
return ('OK', 'plain/text', id))
With POST request
>>> from lambda_proxy.proxy import API
>>> APP = API(app_name="app")
>>> @APP.route('/test/tests/<id>', methods=['POST'], cors=True)
>>> def print_id(id, body):
return ('OK', 'plain/text', id))
Simple Auth token
Lambda-proxy provide a simple token validation system.
a “TOKEN” variable must be set in the environment
each request must provide a “access_token” params (e.g curl http://myurl/test/tests/myid?access_token=blabla)
>>> from lambda_proxy.proxy import API
>>> APP = API(app_name="app")
>>> @APP.route('/test/tests/<id>', methods=['GET'], cors=True, token=True)
>>> def print_id(id):
return ('OK', 'plain/text', id))
URL schema and request parameters
>>> from lambda_proxy.proxy import API
>>> APP = API(app_name="app")
>>> @APP.route('/test/tests/<id>', methods=['GET'], cors=True)
>>> def print_id(id, name=None):
return ('OK', 'plain/text', f"{id}{name}"))
requests:
>>> curl /test/tests/000001
0001
>>> curl /test/tests/000001?name=vincent
0001vincent
License
See LICENSE.txt.
Changes
See CHANGES.txt.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lambda_proxy-1.1.0.tar.gz
(6.0 kB
view details)
File details
Details for the file lambda_proxy-1.1.0.tar.gz
.
File metadata
- Download URL: lambda_proxy-1.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b1e58df1f41b7a3edca95cd77cb5f356f167bb79abc474d532132653928a714 |
|
MD5 | 6f4384ee0627a9055ba44c0f26180f99 |
|
BLAKE2b-256 | c6ef2df48356d7a1d2b659cc984397df1e91889e316c932a9638175bb23b38ae |