Struct rustful::server::Server [] [src]

pub struct Server<R> {
    pub handlers: R,
    pub host: Host,
    pub threads: Option<usize>,
    pub keep_alive: Option<KeepAlive>,
    pub server: String,
    pub content_type: Mime,
    pub global: Global,
    pub context_filters: Vec<Box<ContextFilter>>,
    pub response_filters: Vec<Box<ResponseFilter>>,

Used to set up and run a server.

let server_result = Server {
    host: 8080.into(),
    handlers: router,

match server_result {
    Ok(_server) => {},
    Err(e) => println!("could not start server: {}", e.description())


One or several response handlers.

The host address and port where the server will listen for requests. Default is

The number of threads to be used in the server thread pool. The default (None) will cause the server to optimistically use the formula (num_cores * 5) / 4.

The server's keep-alive policy. Setting this to Some(...) will allow keep-alive connections with a timeout, and keeping it as None will force connections to close after each request. Default is None.

The content of the server header. Default is "rustful".

The default media type. Default is text/plain, charset: UTF-8.

Globally accessible data.

The context filter stack.

The response filter stack.


impl<R: HandleRequest> Server<R>

Set up a new standard server. This can be useful when handlers doesn't implement Default:

let handler = |context: Context, response: Response| {

let server_result = Server {
    host: 8080.into(),

Start the server.

Start the server with SSL.

Build a runnable instance of the server.

Trait Implementations

impl<R: Default + HandleRequest> Default for Server<R>

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl<R> Send for Server<R> where
    R: Send

impl<R> Sync for Server<R> where
    R: Sync