axum-yaml
axum-yaml
adds YAML features to axum
Features
- Serialize, Deserialize YAML from request/response
Usage Example
Extractor example
When used as an extractor, it can deserialize request bodies into some type that implements serde::Deserialize
. If the request body cannot be parsed, or it does not contain the Content-Type: application/yaml
header, it will reject the request and return a 400 Bad Request
response.
use ;
use Yaml;
use Deserialize;
async
let app = new.route;
[!NOTE] Also, you can construct a
Yaml<T>
from a byte slice (Yaml::from_bytes()
). Most users should prefer to use theFromRequest
impl but special cases may require first extracting aRequest
intoBytes
then optionally constructing aYaml<T>
.
Response example
When used as a response, it can serialize any type that implements serde::Serialize
to YAML
, and will automatically set Content-Type: application/yaml
header.
use ;
use Yaml;
use Serialize;
use Uuid;
async
async
let app = new.route;
License
This project is licensed under the MIT license