keiro 0.0.2

A lightweight router for Rust HTTP services.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::Params;
use hyper::{Body, Request};

pub trait RequestExt {
    fn params(&self) -> Option<&Params>;
    fn state<T: Clone + Send + Sync + 'static>(&self) -> Option<&T>;
}

impl RequestExt for Request<Body> {
    fn params(&self) -> Option<&Params> {
        self.extensions().get::<Params>()
    }

    fn state<T: Clone + Send + Sync + 'static>(&self) -> Option<&T> {
        self.extensions().get::<T>()
    }
}