reqores 0.1.7

Oversimplified http request/response abstraction layer
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use serde::Deserialize;

/// The request accepted by the server.
pub trait ServerRequest {
    /// The body of the request.
    fn body(&self) -> &[u8];

    /// the body deserialized with [`serde_json::from_slice`].
    fn body_json<'a, T: Deserialize<'a>>(&'a self) -> serde_json::Result<T> {
        serde_json::from_slice(self.body())
    }

    /// The header value from the given key.
    fn header(&self, key: &str) -> Option<String>;
}