Struct iron::prelude::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: H
Iron contains a Handler
, which it uses to create responses for client
requests.
Methods
impl<H: Handler> Iron<H>
[src]
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 8 * 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, timeouts: Option<Timeouts>) -> 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
.
Trait Implementations
impl<H: Handler> Handler for Iron<H>
[src]
fn handle(&self, http_req: HttpRequest, http_res: HttpResponse<Fresh>)
Receives a Request
/Response
pair, and should perform some action on them. Read more
fn check_continue(&self, (&Method, &RequestUri, &Headers)) -> StatusCode
Called when a Request includes a Expect: 100-continue
header. Read more
fn on_connection_start(&self)
This is run after a connection is received, on a per-connection basis (not a per-request basis, as a connection with keep-alive may handle multiple requests) Read more
fn on_connection_end(&self)
This is run before a connection is closed, on a per-connection basis (not a per-request basis, as a connection with keep-alive may handle multiple requests) Read more