pub struct RouteId(pub u32);Expand description
A declared route (one method of one pattern), numbered in declaration order.
use web_net::{App, get};
use serve_net::{Envelope, HttpReply, HttpRequest, HttpService, Outcome};
// A dispatcher in front of the app that answers with what `classify` said.
struct Probe(App);
impl HttpService for Probe {
fn call(&self, req: &HttpRequest<'_>, _: &Envelope, reply: &mut HttpReply) -> Outcome {
let c = self.0.classify(req.head());
reply.text(200, &format!("{:?} {:?}", c.route, c.work));
Outcome::Done
}
}
let app = App::builder()
.route(get("/", |cx| cx.text(200, "home")))
.route(get("/about", |cx| cx.text(200, "about")))
.build()?;
let r = serve_net::testing::respond(&Probe(app), b"GET /about HTTP/1.1\r\nHost: localhost\r\n\r\n");
assert_eq!(r.text(), "Some(RouteId(1)) Quick");Tuple Fields§
§0: u32Trait Implementations§
impl Copy for RouteId
impl Eq for RouteId
impl StructuralPartialEq for RouteId
Auto Trait Implementations§
impl Forget for RouteId
impl Freeze for RouteId
impl Move for RouteId
impl RefUnwindSafe for RouteId
impl Send for RouteId
impl Sync for RouteId
impl Unpin for RouteId
impl UnsafeUnpin for RouteId
impl UnwindSafe for RouteId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more