Struct warp::Server[][src]

pub struct Server<F> { /* fields omitted */ }
Expand description

A Warp Server ready to filter requests.

Implementations

Run this Server forever on the current thread.

Run this Server forever on the current thread with a specific stream of incoming connections.

This can be used for Unix Domain Sockets, or TLS, etc.

Bind to a socket address, returning a Future that can be executed on the current runtime.

Panics

Panics if we are unable to bind to the provided address.

Bind to a socket address, returning a Future that can be executed on any runtime.

In case we are unable to bind to the specified address, resolves to an error and logs the reason.

Bind to a possibly ephemeral socket address.

Returns the bound address and a Future that can be executed on the current runtime.

Panics

Panics if we are unable to bind to the provided address.

Tried to bind a possibly ephemeral socket address.

Returns a Result which fails in case we are unable to bind with the underlying error.

Returns the bound address and a Future that can be executed on the current runtime.

Create a server with graceful shutdown signal.

When the signal completes, the server will start the graceful shutdown process.

Returns the bound address and a Future that can be executed on the current runtime.

Example
use warp::Filter;
use futures_util::future::TryFutureExt;
use tokio::sync::oneshot;

let routes = warp::any()
    .map(|| "Hello, World!");

let (tx, rx) = oneshot::channel();

let (addr, server) = warp::serve(routes)
    .bind_with_graceful_shutdown(([127, 0, 0, 1], 3030), async {
         rx.await.ok();
    });

// Spawn the server into a runtime
tokio::task::spawn(server);

// Later, start the shutdown...
let _ = tx.send(());

Create a server with graceful shutdown signal.

When the signal completes, the server will start the graceful shutdown process.

Setup this Server with a specific stream of incoming connections.

This can be used for Unix Domain Sockets, or TLS, etc.

Returns a Future that can be executed on the current runtime.

Setup this Server with a specific stream of incoming connections and a signal to initiate graceful shutdown.

This can be used for Unix Domain Sockets, or TLS, etc.

When the signal completes, the server will start the graceful shutdown process.

Returns a Future that can be executed on the current runtime.

Configure a server to use TLS.

This function requires the "tls" feature.

Trait Implementations

Formats the value using the given formatter. Read more

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.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more