Struct humphrey::app::App[][src]

pub struct App<State> where
    State: Send + Sync + 'static, 
{ /* fields omitted */ }
Expand description

Represents the Humphrey app.

The type parameter represents the app state, which is shared between threads. It must implement the Send and Sync traits to be sent between threads. The state is given to every request as an Arc<State>.

Implementations

Initialises a new Humphrey app.

Initialises a new Humphrey app with the given configuration options.

Runs the Humphrey app on the given socket address. This function will only return if a fatal error is thrown such as the port being in use.

Sets the default state for the server. Should only be used in cases where the Default trait cannot be implemented for State. For example, if the default state is dynamically generated as it is in the CLI.

Adds a route and associated handler to the server. Routes can include wildcards, for example /blog/*.

Panics

This function will panic if the route string cannot be converted to a Uri object.

Sets the error handler for the server.

Sets the connection condition, a function which decides whether to accept the connection. For example, this could be used for implementing whitelists and blacklists.

Sets the websocket handler, a function which processes WebSocket handshakes. This is passed the stream, state, and the request which triggered its calling.

Overrides the default connection handler, allowing for manual control over the TCP requests and responses. Not recommended as it basically disables most of the server’s features.

Gets a reference to the app’s state. This should only be used in the main thread, as the state is passed to request handlers otherwise.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.