Coverage for docs_src / custom_response / tutorial009c_py310.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1from typing import Any 1abcd
3import orjson 1abcd
4from fastapi import FastAPI, Response 1abcd
6app = FastAPI() 1abcd
9class CustomORJSONResponse(Response): 1abcd
10 media_type = "application/json" 1abcd
12 def render(self, content: Any) -> bytes: 1abcd
13 assert orjson is not None, "orjson must be installed" 1efg
14 return orjson.dumps(content, option=orjson.OPT_INDENT_2) 1efg
17@app.get("/", response_class=CustomORJSONResponse) 1abcd
18async def main(): 1abcd
19 return {"message": "Hello World"} 1efg