Struct aitch::servers::tiny_http::Server[][src]

pub struct Server<H, ReqBody> where
    H: Handler<ReqBody>,
    ReqBody: Body
{ /* fields omitted */ }

A tiny_http server, which can serve a handler.

This server back-end uses tiny_http to listen for incoming HTTP requests, call the provided Handler, and then return the response to the client.

The server uses the internal thread-pool of tiny_http to construct HTTP requests/responses from the underyling connection. The Handler (and any handlers it may call) are spawned onto a thread-pool managed by tokio-threadpool, and so should not block requests from being processed.

This server is unable to process streaming HTTP request or response bodies. The full request body will be buffered in memory before the provided Handler is called. The full response body will be read from the returned Responder before being sent to the client.

Users who wish to write asynchronous handlers, are encouraged to instead use the hyper back-end.

Example

let addr = "127.0.0.1:3000".parse()?;
aitch::servers::tiny_http::Server::new(addr, handler)?.run()

Methods

impl<H, ReqBody> Server<H, ReqBody> where
    H: Handler<ReqBody>,
    ReqBody: Body
[src]

Creates a server which will listen on the provided SocketAddr and handle requests using the provided Handler.

Returns the address that the server is listening on.

Starts and runs the server.

Auto Trait Implementations

impl<H, ReqBody> Send for Server<H, ReqBody>

impl<H, ReqBody> Sync for Server<H, ReqBody> where
    ReqBody: Sync