Skip to content

Commit

Permalink
Move esmerald Response transform to lilya (#116)
Browse files Browse the repository at this point in the history
* move esmerald response transform to lilya

* bump version
  • Loading branch information
devkral authored Dec 18, 2024
1 parent 9545a4a commit 843edb9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/en/docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ hide:
### Changed

- Move simplify logic from `make_response` to Response but keep old interface.
- Move esmerald Response `transform` to lilya.

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion lilya/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.6"
__version__ = "0.11.7"
7 changes: 7 additions & 0 deletions lilya/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ def with_transform_kwargs(cls, params: dict | None, /) -> Generator[None, None,
finally:
RESPONSE_TRANSFORM_KWARGS.reset(token)

@classmethod
def transform(cls, content: Any) -> Any:
transform_kwargs = RESPONSE_TRANSFORM_KWARGS.get()
if transform_kwargs is None:
transform_kwargs = {}
return json_encode(content, **transform_kwargs)

def make_response(self, content: Any) -> bytes | str:
"""
Makes the Response object type.
Expand Down

0 comments on commit 843edb9

Please sign in to comment.