mimeograph_request/lib.rs
1#![no_std]
2
3extern crate alloc;
4
5use alloc::borrow::Cow;
6
7/// A trait for types that can be routed
8pub trait Request {
9 /// Return the path portion of a URI.
10 fn path(&self) -> Cow<'_, str>;
11
12 /// Returns the http VERB in UPPERCASE
13 fn method(&self) -> Cow<'_, str>;
14}
15
16#[cfg(feature = "http")]
17impl<T> Request for http::Request<T> {
18 fn path(&self) -> Cow<'_, str> {
19 self.uri().path().into()
20 }
21
22 fn method(&self) -> Cow<'_, str> {
23 self.method().as_str().into()
24 }
25}