Skip to content

Commit

Permalink
version 1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Dec 14, 2021
1 parent 68e792e commit 6df6bba
Show file tree
Hide file tree
Showing 15 changed files with 396 additions and 54 deletions.
2 changes: 1 addition & 1 deletion docs/api-docs/slack_bolt/adapter/falcon/resource.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="title">Module <code>slack_bolt.adapter.falcon.resource</code></h1>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from datetime import datetime
<pre><code class="python">from datetime import datetime # type: ignore
from http import HTTPStatus

from falcon import Request, Response
Expand Down
6 changes: 6 additions & 0 deletions docs/api-docs/slack_bolt/adapter/flask/handler.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ <h1 class="title">Module <code>slack_bolt.adapter.flask.handler</code></h1>
def to_flask_response(bolt_resp: BoltResponse) -&gt; Response:
resp: Response = make_response(bolt_resp.body, bolt_resp.status)
for k, values in bolt_resp.headers.items():
if k.lower() == &#34;content-type&#34; and resp.headers.get(&#34;content-type&#34;) is not None:
# Remove the one set by Flask
resp.headers.pop(&#34;content-type&#34;)
for v in values:
resp.headers.add_header(k, v)
return resp
Expand Down Expand Up @@ -107,6 +110,9 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<pre><code class="python">def to_flask_response(bolt_resp: BoltResponse) -&gt; Response:
resp: Response = make_response(bolt_resp.body, bolt_resp.status)
for k, values in bolt_resp.headers.items():
if k.lower() == &#34;content-type&#34; and resp.headers.get(&#34;content-type&#34;) is not None:
# Remove the one set by Flask
resp.headers.pop(&#34;content-type&#34;)
for v in values:
resp.headers.add_header(k, v)
return resp</code></pre>
Expand Down
2 changes: 1 addition & 1 deletion docs/api-docs/slack_bolt/adapter/sanic/async_handler.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="title">Module <code>slack_bolt.adapter.sanic.async_handler</code></h1
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from datetime import datetime
<pre><code class="python">from datetime import datetime # type: ignore

from sanic.request import Request
from sanic.response import HTTPResponse
Expand Down
70 changes: 50 additions & 20 deletions docs/api-docs/slack_bolt/adapter/starlette/async_handler.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,30 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.async_handler</code>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from starlette.requests import Request
<pre><code class="python">from typing import Dict, Any, Optional

from starlette.requests import Request
from starlette.responses import Response

from slack_bolt import BoltResponse
from slack_bolt.async_app import AsyncApp, AsyncBoltRequest
from slack_bolt.oauth.async_oauth_flow import AsyncOAuthFlow


def to_async_bolt_request(req: Request, body: bytes) -&gt; AsyncBoltRequest:
return AsyncBoltRequest(
def to_async_bolt_request(
req: Request,
body: bytes,
addition_context_properties: Optional[Dict[str, Any]] = None,
) -&gt; AsyncBoltRequest:
request = AsyncBoltRequest(
body=body.decode(&#34;utf-8&#34;),
query=req.query_params,
headers=req.headers,
)
if addition_context_properties is not None:
for k, v in addition_context_properties.items():
request.context[k] = v
return request


def to_starlette_response(bolt_resp: BoltResponse) -&gt; Response:
Expand Down Expand Up @@ -67,23 +77,27 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.async_handler</code>
def __init__(self, app: AsyncApp): # type: ignore
self.app = app

async def handle(self, req: Request) -&gt; Response:
async def handle(
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
) -&gt; Response:
body = await req.body()
if req.method == &#34;GET&#34;:
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)
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)
to_async_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)
elif req.method == &#34;POST&#34;:
bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body))
bolt_resp = await self.app.async_dispatch(
to_async_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)

return Response(
Expand All @@ -100,20 +114,28 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.async_handler</code>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="slack_bolt.adapter.starlette.async_handler.to_async_bolt_request"><code class="name flex">
<span>def <span class="ident">to_async_bolt_request</span></span>(<span>req: starlette.requests.Request, body: bytes) ‑> <a title="slack_bolt.request.async_request.AsyncBoltRequest" href="../../request/async_request.html#slack_bolt.request.async_request.AsyncBoltRequest">AsyncBoltRequest</a></span>
<span>def <span class="ident">to_async_bolt_request</span></span>(<span>req: starlette.requests.Request, body: bytes, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> <a title="slack_bolt.request.async_request.AsyncBoltRequest" href="../../request/async_request.html#slack_bolt.request.async_request.AsyncBoltRequest">AsyncBoltRequest</a></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def to_async_bolt_request(req: Request, body: bytes) -&gt; AsyncBoltRequest:
return AsyncBoltRequest(
<pre><code class="python">def to_async_bolt_request(
req: Request,
body: bytes,
addition_context_properties: Optional[Dict[str, Any]] = None,
) -&gt; AsyncBoltRequest:
request = AsyncBoltRequest(
body=body.decode(&#34;utf-8&#34;),
query=req.query_params,
headers=req.headers,
)</code></pre>
)
if addition_context_properties is not None:
for k, v in addition_context_properties.items():
request.context[k] = v
return request</code></pre>
</details>
</dd>
<dt id="slack_bolt.adapter.starlette.async_handler.to_starlette_response"><code class="name flex">
Expand Down Expand Up @@ -165,23 +187,27 @@ <h2 class="section-title" id="header-classes">Classes</h2>
def __init__(self, app: AsyncApp): # type: ignore
self.app = app

async def handle(self, req: Request) -&gt; Response:
async def handle(
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
) -&gt; Response:
body = await req.body()
if req.method == &#34;GET&#34;:
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)
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)
to_async_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)
elif req.method == &#34;POST&#34;:
bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body))
bolt_resp = await self.app.async_dispatch(
to_async_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)

return Response(
Expand All @@ -192,31 +218,35 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<h3>Methods</h3>
<dl>
<dt id="slack_bolt.adapter.starlette.async_handler.AsyncSlackRequestHandler.handle"><code class="name flex">
<span>async def <span class="ident">handle</span></span>(<span>self, req: starlette.requests.Request) ‑> starlette.responses.Response</span>
<span>async def <span class="ident">handle</span></span>(<span>self, req: starlette.requests.Request, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> starlette.responses.Response</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def handle(self, req: Request) -&gt; Response:
<pre><code class="python">async def handle(
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
) -&gt; Response:
body = await req.body()
if req.method == &#34;GET&#34;:
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)
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)
to_async_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)
elif req.method == &#34;POST&#34;:
bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body))
bolt_resp = await self.app.async_dispatch(
to_async_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)

return Response(
Expand Down
76 changes: 56 additions & 20 deletions docs/api-docs/slack_bolt/adapter/starlette/handler.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,29 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.handler</code></h1>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from starlette.requests import Request
<pre><code class="python">from typing import Dict, Any, Optional

from starlette.requests import Request
from starlette.responses import Response

from slack_bolt import BoltRequest, App, BoltResponse
from slack_bolt.oauth import OAuthFlow


def to_bolt_request(req: Request, body: bytes) -&gt; BoltRequest:
return BoltRequest(
def to_bolt_request(
req: Request,
body: bytes,
addition_context_properties: Optional[Dict[str, Any]] = None,
) -&gt; BoltRequest:
request = BoltRequest(
body=body.decode(&#34;utf-8&#34;),
query=req.query_params,
headers=req.headers,
)
if addition_context_properties is not None:
for k, v in addition_context_properties.items():
request.context[k] = v
return request


def to_starlette_response(bolt_resp: BoltResponse) -&gt; Response:
Expand Down Expand Up @@ -66,21 +76,27 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.handler</code></h1>
def __init__(self, app: App): # type: ignore
self.app = app

async def handle(self, req: Request) -&gt; Response:
async def handle(
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
) -&gt; Response:
body = await req.body()
if req.method == &#34;GET&#34;:
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)
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))
bolt_resp = oauth_flow.handle_callback(
to_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)
elif req.method == &#34;POST&#34;:
bolt_resp = self.app.dispatch(to_bolt_request(req, body))
bolt_resp = self.app.dispatch(
to_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)

return Response(
Expand All @@ -97,20 +113,28 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.handler</code></h1>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="slack_bolt.adapter.starlette.handler.to_bolt_request"><code class="name flex">
<span>def <span class="ident">to_bolt_request</span></span>(<span>req: starlette.requests.Request, body: bytes) ‑> <a title="slack_bolt.request.request.BoltRequest" href="../../request/request.html#slack_bolt.request.request.BoltRequest">BoltRequest</a></span>
<span>def <span class="ident">to_bolt_request</span></span>(<span>req: starlette.requests.Request, body: bytes, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> <a title="slack_bolt.request.request.BoltRequest" href="../../request/request.html#slack_bolt.request.request.BoltRequest">BoltRequest</a></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def to_bolt_request(req: Request, body: bytes) -&gt; BoltRequest:
return BoltRequest(
<pre><code class="python">def to_bolt_request(
req: Request,
body: bytes,
addition_context_properties: Optional[Dict[str, Any]] = None,
) -&gt; BoltRequest:
request = BoltRequest(
body=body.decode(&#34;utf-8&#34;),
query=req.query_params,
headers=req.headers,
)</code></pre>
)
if addition_context_properties is not None:
for k, v in addition_context_properties.items():
request.context[k] = v
return request</code></pre>
</details>
</dd>
<dt id="slack_bolt.adapter.starlette.handler.to_starlette_response"><code class="name flex">
Expand Down Expand Up @@ -162,21 +186,27 @@ <h2 class="section-title" id="header-classes">Classes</h2>
def __init__(self, app: App): # type: ignore
self.app = app

async def handle(self, req: Request) -&gt; Response:
async def handle(
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
) -&gt; Response:
body = await req.body()
if req.method == &#34;GET&#34;:
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)
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))
bolt_resp = oauth_flow.handle_callback(
to_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)
elif req.method == &#34;POST&#34;:
bolt_resp = self.app.dispatch(to_bolt_request(req, body))
bolt_resp = self.app.dispatch(
to_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)

return Response(
Expand All @@ -187,29 +217,35 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<h3>Methods</h3>
<dl>
<dt id="slack_bolt.adapter.starlette.handler.SlackRequestHandler.handle"><code class="name flex">
<span>async def <span class="ident">handle</span></span>(<span>self, req: starlette.requests.Request) ‑> starlette.responses.Response</span>
<span>async def <span class="ident">handle</span></span>(<span>self, req: starlette.requests.Request, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> starlette.responses.Response</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def handle(self, req: Request) -&gt; Response:
<pre><code class="python">async def handle(
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
) -&gt; Response:
body = await req.body()
if req.method == &#34;GET&#34;:
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)
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))
bolt_resp = oauth_flow.handle_callback(
to_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)
elif req.method == &#34;POST&#34;:
bolt_resp = self.app.dispatch(to_bolt_request(req, body))
bolt_resp = self.app.dispatch(
to_bolt_request(req, body, addition_context_properties)
)
return to_starlette_response(bolt_resp)

return Response(
Expand Down
2 changes: 1 addition & 1 deletion docs/api-docs/slack_bolt/adapter/tornado/handler.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="title">Module <code>slack_bolt.adapter.tornado.handler</code></h1>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from datetime import datetime
<pre><code class="python">from datetime import datetime # type: ignore

from tornado.httputil import HTTPServerRequest
from tornado.web import RequestHandler
Expand Down
Loading

0 comments on commit 6df6bba

Please sign in to comment.