docs/reference/adapter/starlette/index.html
slack_bolt.adapter.starlette.async_handler
slack_bolt.adapter.starlette.handler
class SlackRequestHandler (app: App)#Expand source code
class SlackRequestHandler:
def __init__ (self, app: App):
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: OAuthFlow = self.app.oauth_flow
if req.url.path == oauth_flow.install_path:
bolt_resp = oauth_flow.handle_installation(to_bolt_request(req, body, addition_context_properties))
return to_starlette_response(bolt_resp)
elif req.url.path == oauth_flow.redirect_uri_path:
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req, body, addition_context_properties))
return to_starlette_response(bolt_resp)
elif req.method == "POST":
bolt_resp = self.app.dispatch(to_bolt_request(req, body, addition_context_properties))
return to_starlette_response(bolt_resp)
return Response(
status_code=404,
content="Not found",
)
async def handle(self,req: starlette.requests.Request,addition_context_properties: Dict[str, Any] | None = None) ‑> starlette.responses.Response#Expand source code
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: OAuthFlow = self.app.oauth_flow
if req.url.path == oauth_flow.install_path:
bolt_resp = oauth_flow.handle_installation(to_bolt_request(req, body, addition_context_properties))
return to_starlette_response(bolt_resp)
elif req.url.path == oauth_flow.redirect_uri_path:
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req, body, addition_context_properties))
return to_starlette_response(bolt_resp)
elif req.method == "POST":
bolt_resp = self.app.dispatch(to_bolt_request(req, body, addition_context_properties))
return to_starlette_response(bolt_resp)
return Response(
status_code=404,
content="Not found",
)