[][src]Function hyperbole::body::bytes

pub async fn bytes(cx: HCons<Body, HNil>) -> Result<HCons<Bytes, HNil>>

Retrieve the request body as a contiguous Bytes buffer.

Use with Ctx::handle_with or Ctx::try_then.

Examples

use bytes::Bytes;
use hyperbole::{body, record_args, uri, Ctx};

#[record_args]
async fn the_thing(_body: Bytes) -> &'static str {
    "got em"
}

let _ctx = Ctx::default()
    // inline with get_with:
    .get_with(uri!["the-thing"], body::bytes, the_thing)
    // or as a middleware:
    .try_then(body::bytes)
    .get(uri!["eht-thing"], the_thing);