Struct aitch::servers::hyper::Server [−][src]
A hyper
server, which can serve a handler.
This server back-end uses hyper
to listen for incoming HTTP requests, call the provided
Handler
, and then return the response to the client.
The server uses the default tokio
runtime to serve requests, which uses a separate reactor
to drive I/O resources, and a thread-pool which uses those I/O resources to construct HTTP
requests/responses. The provided handler (and any handlers it may call) are all run on this
thread-pool.
Example
let addr = "127.0.0.1:3000".parse()?; aitch::servers::hyper::Server::new(addr, handler)?.run()
Methods
impl<H, ReqBody> Server<H, ReqBody> where
H: Handler<ReqBody>,
ReqBody: Body,
[src]
impl<H, ReqBody> Server<H, ReqBody> where
H: Handler<ReqBody>,
ReqBody: Body,
pub fn new(addr: SocketAddr, handler: H) -> Result<Server<H, ReqBody>>
[src]
pub fn new(addr: SocketAddr, handler: H) -> Result<Server<H, ReqBody>>
Creates a server which will listen on the provided SocketAddr
and handle requests using
the provided Handler
.
pub fn addr(&self) -> SocketAddr
[src]
pub fn addr(&self) -> SocketAddr
Returns the address that the server is listening on.
pub fn run(self) -> Result<()>
[src]
pub fn run(self) -> Result<()>
Starts and runs the server.