-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add WSGI adapter #1085
feat: add WSGI adapter #1085
Conversation
Can you check the flake8 errors? https://github.com/slackapi/bolt-python/actions/runs/9228875341/job/25393855815?pr=1085 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. This is a nice addition! Once you clean up things, we can go ahead with merging the change for the next minor release.
slack_bolt/adapter/wsgi/utils.py
Outdated
@@ -0,0 +1 @@ | |||
ENCODING = "utf-8" # should always be utf-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for Slack apps but perhaps the comment should be clearer to clarify we understand this is not true for WSGI in general:
ENCODING = "utf-8" # should always be utf-8 | |
ENCODING = "utf-8" # The content encoding for Slack requests/responses is always utf-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's good to rename this file to "intenrals.py" for consistency with other source files in this project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the file to internals.py
and updated the comment 💯
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1085 +/- ##
=======================================
Coverage 91.76% 91.76%
=======================================
Files 181 186 +5
Lines 6315 6403 +88
=======================================
+ Hits 5795 5876 +81
- Misses 520 527 +7 ☔ View full report in Codecov by Sentry. |
name = key.lower().replace("_", "-") | ||
headers[name] = value | ||
if key.startswith("HTTP_"): | ||
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out the black formatter was cause the Flake8 issue, the workaround if to add # fmt: skip
on the line causing the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Black Formatter will add a whitespace between len("HTTP_")
and :
, Flake8 does not align with this syntax, the Black Formatter does not allow ignoring specific rules
key[len("HTTP_") :].lower().replace("_", "-")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes sense; thanks for clarifying it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you; looks great to me 👍
name = key.lower().replace("_", "-") | ||
headers[name] = value | ||
if key.startswith("HTTP_"): | ||
name = key[len("HTTP_"):].lower().replace("_", "-") # fmt: skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes sense; thanks for clarifying it
This PR introduced a WSGI adapter to bolt python, this will allow Bolt to be deployed in production without the need for an other WSGI compatible Web Framework like Flask
Testing
examples/wsgi/app.py
as starting point for a test appscripts/build_pypi_package.sh
.whl
file found underdist/
to runpip install /path/to/dist/slack_bolt.whl
pip install gunicorn
gunicorn app:api -b 0.0.0.0:3000 --log-level debug
to start the applicationCategory
slack_bolt.App
and/or its core componentsslack_bolt.async_app.AsyncApp
and/or its core componentsslack_bolt.adapter
/docs
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
./scripts/install_all_and_run_tests.sh
after making the changes.