oxidized 0.1.0

A hyper-performant, modular, and asynchronous web framework for Rust, built on hyper and tokio. Featuring a Tower-inspired, Service-based architecture for maximum performance and composability.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::{
    extractor::FromRequest,
    http_request::{Body, RequestParts},
    Error, Result,
};
use async_trait::async_trait;
use http_body_util::BodyExt;

#[async_trait]
impl FromRequest for String {
    async fn from_request(_parts: &mut RequestParts, body: Body) -> Result<Self> {
        let body_bytes = body.collect().await.map_err(|_| Error::NotFound)?.to_bytes();
        String::from_utf8(body_bytes.to_vec()).map_err(|_| Error::NotFound)
    }
}