Skip to main content

parse parameters

Project description

purus

purus parses parameters provided from AWS services. It is named after The Purus River, or a tributary of The Amazon River.

Install

$ pip install purus

Usage

CloudFront:Lambda@Edge

purus can parse parameters of

  • viewer-request
  • origin-request
  • origin-response
  • viewer-response
# Lambda@Edge
from purus.amazon_cloudfront import CloudFrontLambdaEdge

# on viewer-request or origin-request
def lambda_handler(event: dict, _):
    data = event["Records"][0]["cf"]
    # load data
    lambda_edge = CloudFrontLambdaEdge.from_dict(data=data)
    
    # return on error
    if some_error_occurred:
        response = lambda_edge.add_pseudo_response(
            status="400",
            status_description="error_occurred"
        )
        return response
    
    # add headers to request
    modified_request = lambda_edge.append_request_header(
        key="X-Original-Header",
        value="Your data"
    ).append_request_header(
        key="X-Original-Header",
        value="Your additional data"
    )
    
    # to request
    return  modified_request.request

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

purus-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

purus-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file purus-0.1.0.tar.gz.

File metadata

  • Download URL: purus-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.15 CPython/3.10.6 Darwin/21.6.0

File hashes

Hashes for purus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4b2ff0f49766ed5b43fcc9205d04a3739eda5dd5723f928c57abb19cccfeb09d
MD5 2aee86e9bce830674805cc7d7edac125
BLAKE2b-256 9880432c6bf2cbe414877cf79f047972f09481acb5d649edffc7bff3dbcae616

See more details on using hashes here.

File details

Details for the file purus-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: purus-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.15 CPython/3.10.6 Darwin/21.6.0

File hashes

Hashes for purus-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a6c77e69325e40f962cd7197be22ff553497f0be3f6f96ea15195cb93ed9c2e
MD5 260eec57af627d1269fc25a753ea0f19
BLAKE2b-256 1cd9460a0aef5ea2606deab02b14c51514c5cd15c60643c5869f2fdae5f7058e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page