Struct actix_web::HttpServer [] [src]

pub struct HttpServer<H> where
    H: IntoHttpHandler + 'static, 
{ /* fields omitted */ }

An HTTP Server

Methods

impl<H> HttpServer<H> where
    H: IntoHttpHandler + 'static, 
[src]

[src]

Create new http server with application factory

[src]

Set number of workers to start.

By default http server uses number of available logical cpu as threads count.

[src]

Set the maximum number of pending connections.

This refers to the number of clients that can be waiting to be served. Exceeding this number results in the client getting an error when attempting to connect. It should only affect servers under significant load.

Generally set in the 64-2048 range. Default value is 2048.

This method should be called before bind() method call.

[src]

Set server keep-alive setting.

By default keep alive is set to a Os.

[src]

Set server host name.

Host name is used by application router aa a hostname for url generation. Check ConnectionInfo documentation for more information.

[src]

Send SystemExit message to actix system

SystemExit message stops currently running system arbiter and all nested arbiters.

[src]

Set alternative address for ProcessSignals actor.

[src]

Disable signal handling

[src]

Timeout for graceful workers shutdown.

After receiving a stop signal, workers have this much time to finish serving requests. Workers still alive after the timeout are force dropped.

By default shutdown timeout sets to 30 seconds.

Important traits for Vec<u8>
[src]

Get addresses of bound sockets.

[src]

Use listener for accepting incoming connection requests

HttpServer does not change any configuration for TcpListener, it needs to be configured before passing it to listen() method.

[src]

The socket address to bind

To mind multiple addresses this method can be call multiple times.

impl<H: IntoHttpHandler> HttpServer<H>
[src]

[src]

Start listening for incoming connections.

This method starts number of http handler workers in separate threads. For each address this method starts separate thread which does accept() in a loop.

This methods panics if no socket addresses get bound.

This method requires to run within properly configured Actix system.

extern crate actix;
extern crate actix_web;
use actix_web::*;

fn main() {
    let sys = actix::System::new("example");  // <- create Actix system

    HttpServer::new(
        || Application::new()
             .resource("/", |r| r.h(httpcodes::HttpOk)))
        .bind("127.0.0.1:0").expect("Can not bind to 127.0.0.1:0")
        .start();

   let _ = sys.run();  // <- Run actix system, this method actually starts all async processes
}

[src]

Spawn new thread and start listening for incoming connections.

This method spawns new thread and starts new actix system. Other than that it is similar to start() method. This method blocks.

This methods panics if no socket addresses get bound.

This example is not tested
use actix_web::*;

fn main() {
    HttpServer::new(
        || Application::new()
             .resource("/", |r| r.h(httpcodes::HttpOk)))
        .bind("127.0.0.1:0").expect("Can not bind to 127.0.0.1:0")
        .run();
}

impl<H: IntoHttpHandler> HttpServer<H>
[src]

[src]

Start listening for incoming connections from a stream.

This method uses only one thread for handling incoming connections.

Trait Implementations

impl<H> Sync for HttpServer<H> where
    H: IntoHttpHandler
[src]

impl<H> Send for HttpServer<H> where
    H: IntoHttpHandler
[src]

impl<H> Actor for HttpServer<H> where
    H: IntoHttpHandler
[src]

Actor execution context type

[src]

Method is called when actor get polled first time.

[src]

Method is called after an actor is in Actor::Stopping state. There could be several reasons for stopping. Context::stop get called by the actor itself. All addresses to current actor get dropped and no more evented objects left in the context. Read more

[src]

Method is called after an actor is stopped, it can be used to perform any needed cleanup work or spawning more actors. This is final state, after this call actor get dropped. Read more

[src]

Start new asynchronous actor, returns address of newly created actor. Read more

[src]

Start new asynchronous actor, returns address of newly created actor.

[src]

Use create method, if you need Context object during actor initialization. Read more

impl<H: IntoHttpHandler> Handler<Signal> for HttpServer<H>
[src]

Signals support Handle SIGINT, SIGTERM, SIGQUIT signals and send SystemExit(0) message to System actor.

The type of value that this handle will return

[src]

Method is called for every message received by this Actor

impl<H: IntoHttpHandler> Handler<PauseServer> for HttpServer<H>
[src]

The type of value that this handle will return

[src]

Method is called for every message received by this Actor

impl<H: IntoHttpHandler> Handler<ResumeServer> for HttpServer<H>
[src]

The type of value that this handle will return

[src]

Method is called for every message received by this Actor

impl<H: IntoHttpHandler> Handler<StopServer> for HttpServer<H>
[src]

The type of value that this handle will return

[src]

Method is called for every message received by this Actor

Auto Trait Implementations