Skip to content

Commit

Permalink
Only prefix a slash on the api_gateway_base_path if needed (#138)
Browse files Browse the repository at this point in the history
* Only prefix a slash on the api_gateway_base_path if needed

* Improve readability and compatibility with black python linter

Co-authored-by: DJ Spatoulas <djs@knowbe4.com>
  • Loading branch information
dspatoulas and DJ Spatoulas committed Sep 28, 2020
1 parent f83e42b commit dc16f7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

# IDE Settings
.idea/
6 changes: 5 additions & 1 deletion mangum/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ def __post_init__(self, enable_lifespan: bool) -> None:
"Invalid argument supplied for `log_level`. "
"Choices are: critical|error|warning|info|debug"
)
if self.api_gateway_base_path:
should_prefix_base_path = (
self.api_gateway_base_path
and not self.api_gateway_base_path.startswith("/")
)
if should_prefix_base_path:
self.api_gateway_base_path = f"/{self.api_gateway_base_path}"
if self.text_mime_types:
self.text_mime_types = self.text_mime_types + DEFAULT_TEXT_MIME_TYPES
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pytest-cov
black
starlette
quart; python_version == '3.7'
dataclasses; python_version < '3.7'
moto
mypy

Expand Down

0 comments on commit dc16f7f

Please sign in to comment.