Crate router_service

source ·
Expand description

A simple no-frills router that can be used as a Service.

Example

use std::convert::Infallible;
use std::net::SocketAddr;

use http::{Request, Response, StatusCode};
use hyper::{Server, Body};
use tower::{Service, make::Shared};
use router_service::Router;

let mut router = Router::new()
    .get("/", |req, _| async move {
        println!("Got request with headers: {:#?}", req.headers());
        Response::builder().body(Body::empty())
    });

 let addr = ([127, 0, 0, 1], 3030).into();
 Server::bind(&addr)
    .serve(Shared::new(router))
    .await
    .expect("error running server");

Modules

Structs