Struct ferrum::Ferrum
[−]
[src]
pub struct Ferrum<H> where
H: Handler, { pub handler: H, pub keep_alive: bool, pub timeout: Option<Duration>, pub num_threads: usize, }
The primary entrance point to Ferrum
, a struct
to instantiate a new server.
Ferrum
contains the Handler
which takes a Request
and produces a Response
.
Fields
handler: H
Ferrum contains a Handler
, which it uses to create responses for client requests.
keep_alive: bool
Controls the timeout for keep alive connections.
The default is true
.
timeout: Option<Duration>
Server timeout.
num_threads: usize
The number of request handling threads.
Defaults to num_cpus
.
Methods
impl<H> Ferrum<H> where
H: Handler,
[src]
H: Handler,
fn new(handler: H) -> Ferrum<H>
[src]
Instantiate a new instance of Ferrum
.
This will create a new Ferrum
, the base unit of the server, using the
passed in Handler
.
fn http<A>(self, addr: A) -> HyperResult<()> where
A: ToSocketAddrs,
[src]
A: ToSocketAddrs,
Kick off the server process using the HTTP protocol.
Call this once to begin listening for requests on the server. This consumes the Ferrum instance. This method will block the current thread executing the HTTP server.
fn server<A>(self, addr: A) -> HyperResult<Server<H>> where
A: ToSocketAddrs,
[src]
A: ToSocketAddrs,
Bind the provided addr
and return a server ready to handle
connections.