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,
    ..Server::default()
}.run();

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

Fields

One or several response handlers.

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

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.

Methods

impl<R: HandleRequest> Server<R>
[src]

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(),
    ..Server::new(handler)
};

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>
[src]

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