This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(response): makes serializer configurable. (#84)
The custom response class only exists to deliver this. So that is now dynamically constructed with the serializer passed to `PluginConfig` if `do_response_class` is `True` and `response_class` doesn't already exist on `AppConfig`. Closes #51
- Loading branch information
1 parent
9e89434
commit 3439d26
Showing
4 changed files
with
35 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Default serializer used by plugin if one not provided.""" | ||
from typing import Any | ||
|
||
from asyncpg.pgproto import pgproto | ||
from starlite import Response | ||
|
||
|
||
def default_serializer(value: Any) -> Any: | ||
"""Serialize `value`. | ||
Args: | ||
value: To be serialized. | ||
Returns: | ||
Serialized representation of `value`. | ||
""" | ||
if isinstance(value, pgproto.UUID): | ||
return str(value) | ||
return Response[Any].serializer(value) |