Struct iron::Iron
[−]
[src]
pub struct Iron<H> { pub handler: H, // some fields omitted }
The primary entrance point to Iron
, a struct
to instantiate a new server.
Iron
contains the Handler
which takes a Request
and produces a
Response
.
Fields
handler | Iron contains a |
Methods
impl<H: Handler> Iron<H>
fn http<A: ToSocketAddrs>(self, addr: A) -> HttpResult<Listening>
Kick off the server process using the HTTP protocol.
Call this once to begin listening for requests on the server. This consumes the Iron instance, but does the listening on another task, so is not blocking.
The thread returns a guard that will automatically join with the parent once it is dropped, blocking until this happens.
Defaults to a threadpool of size 2 * num_cpus
.
Panics
Panics if the provided address does not parse. To avoid this
call to_socket_addrs
yourself and pass a parsed SocketAddr
.
fn https<A: ToSocketAddrs>(self, addr: A, certificate: PathBuf, key: PathBuf) -> HttpResult<Listening>
Kick off the server process using the HTTPS protocol.
Call this once to begin listening for requests on the server. This consumes the Iron instance, but does the listening on another task, so is not blocking.
The thread returns a guard that will automatically join with the parent once it is dropped, blocking until this happens.
Defaults to a threadpool of size 2 * num_cpus
.
Panics
Panics if the provided address does not parse. To avoid this
call to_socket_addrs
yourself and pass a parsed SocketAddr
.
fn listen_with<A: ToSocketAddrs>(self, addr: A, threads: usize, protocol: Protocol) -> HttpResult<Listening>
Kick off the server process with X threads.
Panics
Panics if the provided address does not parse. To avoid this
call to_socket_addrs
yourself and pass a parsed SocketAddr
.
fn new(handler: H) -> Iron<H>
Instantiate a new instance of Iron
.
This will create a new Iron
, the base unit of the server, using the
passed in Handler
.