1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#![no_std]

extern crate alloc;

use alloc::borrow::Cow;

/// A trait for types that can be routed
pub trait Request {
    /// Return the path portion of a URI.
    fn path(&self) -> Cow<'_, str>;

    /// Returns the http VERB in UPPERCASE
    fn method(&self) -> Cow<'_, str>;
}

#[cfg(feature = "http")]
impl<T> Request for http::Request<T> {
    fn path(&self) -> Cow<'_, str> {
        self.uri().path().into()
    }

    fn method(&self) -> Cow<'_, str> {
        self.method().as_str().into()
    }
}