mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 04:57:54 +00:00
Merge branch 'long2ice:main' into fix/piclke-coder
This commit is contained in:
@@ -7,6 +7,7 @@ from typing import Any
|
||||
|
||||
import pendulum
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from starlette.responses import JSONResponse
|
||||
from starlette.templating import _TemplateResponse as TemplateResponse
|
||||
|
||||
CONVERTERS = {
|
||||
@@ -52,6 +53,8 @@ class Coder:
|
||||
class JsonCoder(Coder):
|
||||
@classmethod
|
||||
def encode(cls, value: Any) -> str:
|
||||
if isinstance(value, JSONResponse):
|
||||
return value.body
|
||||
return json.dumps(value, cls=JsonEncoder)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user