-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template per Response Code #16
Comments
Hi, I'd recommend implementing an exception handler middleware that converts exceptions to HTML responses. The middleware has access to the request, it can check whether it was an FastAPI must resolve dependencies (and validate the route's data inputs) before calling the route, so if the API's input is incorrect, FastAPI will raise an Regarding the response code: if your route returns a I assume you only want to differentiate between a successful response and error cases. If the returned error HTML is fairly generic (part of its content could come from Peter |
Closing for lack of response. |
Hey,
would it be possible to define a template per response code? This would make it easier, to render a different template, e.g. in case of validation errors of API input or other situations (e.g. item not found ...).
I understand that it would likely also be possible to have that logic within the template (if the response object is made available), but it might be need lees boilerplate code to be able to see that directly in the Python code.
Henning
The text was updated successfully, but these errors were encountered: