Module slack_bolt.adapter.starlette.async_handler

Functions

def to_async_bolt_request(req: starlette.requests.Request, body: bytes, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> AsyncBoltRequest
def to_starlette_response(bolt_resp: BoltResponse) ‑> starlette.responses.Response

Classes

class AsyncSlackRequestHandler (app: AsyncApp)
Expand source code
class AsyncSlackRequestHandler:
    def __init__(self, app: AsyncApp):
        self.app = app

    async def handle(self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None) -> Response:
        body = await req.body()
        if req.method == "GET":
            if self.app.oauth_flow is not None:
                oauth_flow: AsyncOAuthFlow = self.app.oauth_flow
                if req.url.path == oauth_flow.install_path:
                    bolt_resp = await oauth_flow.handle_installation(
                        to_async_bolt_request(req, body, addition_context_properties)
                    )
                    return to_starlette_response(bolt_resp)
                elif req.url.path == oauth_flow.redirect_uri_path:
                    bolt_resp = await oauth_flow.handle_callback(
                        to_async_bolt_request(req, body, addition_context_properties)
                    )
                    return to_starlette_response(bolt_resp)
        elif req.method == "POST":
            bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body, addition_context_properties))
            return to_starlette_response(bolt_resp)

        return Response(
            status_code=404,
            content="Not found",
        )

Methods

async def handle(self, req: starlette.requests.Request, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> starlette.responses.Response