You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today all Axum extractors (Json, etc), upon an error action (e.g. in case of Json, malformed JSON), will return what Axum thinks is best practice (usually what they think is the best error code and textual response if any).
With Loco, we'd like to customize it in a way that the shape or amount of information is different.
The technical way to do this with Axum is to create a "wrapper" extractor with the custom error logic, like here.
This means we need to create an array of all of the most used / available extractors and offer these instead of users using the Axum extractors direct.
Implementing the wrapper extractor
Once we're in the wrapper extractor, we need to:
let the original extractor do most of the heavy lifting
shape the original error into a suitable loco_rs::Error, whether it is a validation error or something else
On the way out, in the "into response" conversion, we need to set the shape of the error the user will see, and decide if we want to expose the details public or not.
The mapping between: Extractor <> Extractor Error space <> Loco error space <> public http shape is not spec'd yet and is more of a conceptual issue that needs to be researched first.
The text was updated successfully, but these errors were encountered:
Today all Axum extractors (
Json
, etc), upon an error action (e.g. in case ofJson
, malformed JSON), will return what Axum thinks is best practice (usually what they think is the best error code and textual response if any).With Loco, we'd like to customize it in a way that the shape or amount of information is different.
The technical way to do this with Axum is to create a "wrapper" extractor with the custom error logic, like here.
This means we need to create an array of all of the most used / available extractors and offer these instead of users using the Axum extractors direct.
Implementing the wrapper extractor
Once we're in the wrapper extractor, we need to:
loco_rs::Error
, whether it is a validation error or something elseOn the way out, in the "into response" conversion, we need to set the shape of the error the user will see, and decide if we want to expose the details public or not.
The mapping between:
Extractor <> Extractor Error space <> Loco error space <> public http shape
is not spec'd yet and is more of a conceptual issue that needs to be researched first.The text was updated successfully, but these errors were encountered: