How to use the mangum.asgi.protocol.ASGICycle function in mangum

To help you get started, we’ve selected a few mangum examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github erm / mangum / mangum / platforms / azure / adapter.py View on Github external
import urllib.parse
from azure.functions import HttpRequest, HttpResponse
from mangum.asgi.protocol import ASGICycle
from mangum.asgi.adapter import ServerlessAdapter
from mangum.utils import encode_query_string, maybe_encode


class AzureFunctionCycle(ASGICycle):
    """
    An adapter that handles the HTTP request-response cycle for an ASGI application and
    builds a valid response to return to Azure Functions.

    The response is a Python dictionary with the following structure:

        {
            "body": bytes,
            "charset": str,
            "headers": dict,
            "mimetype": str,
            "status_code": itnt
        }
    """

    def on_response_start(self, headers: dict, status_code: int) -> None:
github erm / mangum / mangum / platforms / aws / adapter.py View on Github external
import base64
from mangum.utils import encode_query_string, maybe_encode
from mangum.asgi.protocol import ASGICycle
from mangum.asgi.adapter import ServerlessAdapter


class AWSLambdaASGICycle(ASGICycle):
    """
    An adapter that handles the HTTP request-response cycle for an ASGI application and
    builds a valid response to return to AWS Lambda & API Gateway.

    The response is a Python dictionary with the following structure:

        {
            "statusCode": int,
            "isBase64Encoded": bool,
            "headers": dict,
            "body": str,
        }
    """

    def __init__(self, *args, **kwargs) -> None:
        self.binary = kwargs.pop("binary", False)