Json-resp
This crate provides a success and an error response for Apis, with utilities and macros to ease the generation
of responses and openapi docs(with openapi
feature).(Only axum supported right now)
Check out the examples for full explanation.
Success
The success response looks like:
{
"status": 200,
"content": C, // C should implement serde::Serialize
"meta": M // M should implement serde::Serialize
}
And can be produces with builder pattern:
.meta
with_content
Errors
The error response looks like:
{
"status": 404,
"code": "error code here",
"hint": "do something", // Optional
"content": C // C should implement serde::Serialize
}
And can be produces with a derive macro, openapi docs will be generated too.
And just use it in your handlers:
async