pub struct Ferrum<H>where
H: Handler,{
pub handler: H,
pub keep_alive: bool,
pub timeout: Option<Duration>,
pub num_threads: usize,
}Expand description
Server
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: HFerrum contains a Handler, which it uses to create responses for client requests.
keep_alive: boolControls the timeout for keep alive connections.
The default is true.
timeout: Option<Duration>Server timeout.
num_threads: usizeThe number of request handling threads.
Defaults to num_cpus.
Implementations§
Source§impl<H> Ferrum<H>where
H: Handler,
impl<H> Ferrum<H>where
H: Handler,
Sourcepub fn new(handler: H) -> Ferrum<H>
pub fn new(handler: H) -> Ferrum<H>
Instantiate a new instance of Ferrum.
This will create a new Ferrum, the base unit of the server, using the
passed in Handler.
Sourcepub fn http<A>(self, addr: A) -> HyperResult<()>where
A: ToSocketAddrs,
pub fn http<A>(self, addr: A) -> HyperResult<()>where
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.
Sourcepub fn server<A>(self, addr: A) -> HyperResult<Server<H>>where
A: ToSocketAddrs,
pub fn server<A>(self, addr: A) -> HyperResult<Server<H>>where
A: ToSocketAddrs,
Bind the provided addr and return a server ready to handle
connections.