sanic-org / sanic-ext

Extended Sanic functionality
https://sanic.dev/en/plugins/sanic-ext/getting-started.html
MIT License
50 stars 36 forks source link

Template: reuse LazyResponse for rendered response #244

Open Huy-Ngo opened 8 months ago

Huy-Ngo commented 8 months ago

Previously, only status, headers, and content type are passed to the final rendered response. After this change, the LazyResponse is preserved and only has its body changed after rendering. This allows for, e.g., setting cookie for the LazyResponse.

Huy-Ngo commented 8 months ago

(Leaving this as draft because I haven't written tests and update the doc for this.)

Huy-Ngo commented 8 months ago

Fixed up the tests. I see OAS tests failing, but that's not related. I want to add a test with cookies but response.cookies doesn't seem to return a CookieJar as documented but rather httpx.Cookie, which is weird.

Not sure where to write doc though.