spacegate-kernel 0.2.0-alpha.4

A library-first, lightweight, high-performance, cloud-native supported API gateway
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::{BoxResult, SgRequest};

/// Dump the request body.
/// # Errors
/// 1. Fail to dump the body.
pub async fn dump(req: SgRequest) -> BoxResult<SgRequest> {
    if req.body().is_dumped() {
        Ok(req)
    } else {
        let (parts, body) = req.into_parts();
        let body = body.dump().await?;
        Ok(SgRequest::from_parts(parts, body))
    }
}