Module slack_bolt.adapter.pyramid

Expand source code
from .handler import SlackRequestHandler

__all__ = [
    "SlackRequestHandler",
]

Sub-modules

slack_bolt.adapter.pyramid.handler

Classes

class SlackRequestHandler (app: App)
Expand source code
class SlackRequestHandler:
    def __init__(self, app: App):  # type: ignore
        self.app = app

    def handle(self, request: Request) -> Response:
        if request.method == "GET":
            if self.app.oauth_flow is not None:
                oauth_flow: OAuthFlow = self.app.oauth_flow
                if request.path == oauth_flow.install_path:
                    bolt_req = _attach_pyramid_request_to_context(to_bolt_request(request), request)
                    bolt_resp = oauth_flow.handle_installation(bolt_req)
                    return to_pyramid_response(bolt_resp)
                elif request.path == oauth_flow.redirect_uri_path:
                    bolt_req = _attach_pyramid_request_to_context(to_bolt_request(request), request)
                    bolt_resp = oauth_flow.handle_callback(bolt_req)
                    return to_pyramid_response(bolt_resp)
        elif request.method == "POST":
            bolt_req = _attach_pyramid_request_to_context(to_bolt_request(request), request)
            bolt_resp = self.app.dispatch(bolt_req)
            return to_pyramid_response(bolt_resp)

        return Response(status=404, body="Not found")

Methods

def handle(self, request: pyramid.request.Request) ‑> pyramid.response.Response
Expand source code
def handle(self, request: Request) -> Response:
    if request.method == "GET":
        if self.app.oauth_flow is not None:
            oauth_flow: OAuthFlow = self.app.oauth_flow
            if request.path == oauth_flow.install_path:
                bolt_req = _attach_pyramid_request_to_context(to_bolt_request(request), request)
                bolt_resp = oauth_flow.handle_installation(bolt_req)
                return to_pyramid_response(bolt_resp)
            elif request.path == oauth_flow.redirect_uri_path:
                bolt_req = _attach_pyramid_request_to_context(to_bolt_request(request), request)
                bolt_resp = oauth_flow.handle_callback(bolt_req)
                return to_pyramid_response(bolt_resp)
    elif request.method == "POST":
        bolt_req = _attach_pyramid_request_to_context(to_bolt_request(request), request)
        bolt_resp = self.app.dispatch(bolt_req)
        return to_pyramid_response(bolt_resp)

    return Response(status=404, body="Not found")