A set of utility tools (planned mostly to be decorators) for Google Cloud Functions
Project description
Google Cloud Functions Tools
A set of utility functions are provided, especially developed for Google Cloud Functions (might work on other serverless platforms too). The functions planned are mostly to be decorators.
CORS
Adds CORS headers to your function. Responds to OPTIONS
request by sending CORS headers and without triggering the cloud function. Provided that Google Cloud Funtions use Flask for underlying logic, the return types must be compatible with Flask's.
For example:
@cors
def run(request):
return 'Response text'
sets the following headers by default:
Access-Control-Allow-Origin: '*'
Access-Control-Allow-Methods: 'POST'
Access-Control-Allow-Headers: ''
Access-Control-Max-Age: 3600
However, these default values might change at any time, therefore it is better to specify headers explicitly:
@cors(origin='sample_origin',
methods='GET',
headers='Content-Type',
max_age=9600)
def run(request):
return 'Response text', 200
sets the following headers:
Access-Control-Allow-Origin: 'sample_origin'
Access-Control-Allow-Methods: 'GET'
Access-Control-Allow-Headers: 'Content-Type'
Access-Control-Max-Age: 9600
The method warns if Access-Control-Allow-Origin
header is set to '*'
:
UserWarning: Setting Access-Control-Allow-Origin header to '*' is discouraged. It should not be used in production environments.
Contibuting
Pull requests and issues are welcomed. New functions are planned to be added in time when they are needed.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for google_cloud_functions_tools-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4edeaf665a14d153a52d641afbb9e9604225e0bc2d00086c223f95f7d6dcea64 |
|
MD5 | ccf93fbb9a5ec261d81598be84b16490 |
|
BLAKE2b-256 | 90fda060534f36fd9b77494f8ff72eb097ea51605c248f4a2b170eec7a88f796 |
Hashes for google_cloud_functions_tools-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f860ee1ad3ce7855177cb9c3756ef01a0e8f7d2c28b5618a31910a3e9cac854 |
|
MD5 | 1e102235dca38a45003df1e56eef899e |
|
BLAKE2b-256 | 13d7d8d527a9fed47942e1695721beb30118bdebebc0a813408b17c5a6323b93 |