Skip to content

Commit

Permalink
Allow both postgresql/postgres as dsn schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaneremieff committed May 9, 2020
1 parent 2ccd150 commit 04af620
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ handler = Mangum(

Defaults to the `AWS_REGION` value in the AWS Lambda environment.


### Event and context

The AWS Lambda handler has `event` and `context` parameters. These are available in the ASGI `scope` object:

```python
scope['aws.event']
scope['aws.context']
```


## Examples

The examples below are ASGI applications (non-framework) with minimal configurations. You should be able to replace the `app` in these example with most ASGI framework application instances. Please read the [HTTP](https://erm.github.io/mangum/http/) and [WebSocket](https://erm.github.io/mangum/websocket/) docs for more detailed configuration information.
Expand Down
13 changes: 13 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

Mangum is an adapter for using [ASGI](https://asgi.readthedocs.io/en/latest/) applications with AWS Lambda & API Gateway. It is intended to provide an easy-to-use, configurable wrapper for any ASGI application deployed in an AWS Lambda function to handle API Gateway requests and responses.

***Documentation***: https://mangum.io/

## Features

- API Gateway support for [HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html), [REST](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-rest-api.html), and [WebSocket](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html) APIs.
Expand Down Expand Up @@ -116,6 +118,17 @@ handler = Mangum(

Defaults to the `AWS_REGION` value in the AWS Lambda environment.


### Event and context

The AWS Lambda handler has `event` and `context` parameters. These are available in the ASGI `scope` object:

```python
scope['aws.event']
scope['aws.context']
```


## Examples

The examples below are ASGI applications (non-framework) with minimal configurations. You should be able to replace the `app` in these example with most ASGI framework application instances. Please read the [HTTP](https://erm.github.io/mangum/http/) and [WebSocket](https://erm.github.io/mangum/websocket/) docs for more detailed configuration information.
Expand Down
3 changes: 0 additions & 3 deletions mangum/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ class WebSocketError(Exception):

class ConfigurationError(Exception):
"""Raise when an error occurs parsing configuration."""

# def __init__(self, param: str) -> None:
# super().__init__(f"Missing {param} in configuration")
1 change: 1 addition & 0 deletions mangum/protocols/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class WebSocketCycleState(enum.Enum):

@dataclass
class WebSocketCycle:

websocket: WebSocket
log_level: str
state: WebSocketCycleState = WebSocketCycleState.REQUEST
Expand Down
2 changes: 1 addition & 1 deletion mangum/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __post_init__(self) -> None:

self._backend = S3Backend(self.dsn) # type: ignore

elif scheme == "postgresql":
elif scheme in ("postgresql", "postgres"):
from mangum.backends.postgresql import PostgreSQLBackend

self._backend = PostgreSQLBackend(self.dsn) # type: ignore
Expand Down

0 comments on commit 04af620

Please sign in to comment.