Rust

server

Module

The HTTP/1.1 server on hyper: serves an application on a TCP socket.

It caps the requests in flight server-wide (503 past the cap), drains in-flight requests on shutdown up to a deadline, disables Nagle, leaves compression to the application, sends header names in Title-Case, and gives each request a fresh context whose parent is the application's static resources.

Contents

use utopia_http::App;
Rust
pub struct App(/// The application. pub Arc<Http>)

Serves an Http application: each request runs Http::run in a fresh context.

use utopia_http::ServerOptions;
Rust
pub struct ServerOptions

Server tuning for serve.

Also implements Default, From.
use utopia_http::Settings;
Rust
pub struct Settings

The server settings of a Mode, with the CPU count limited by the cgroup quota. ServerOptions can be built from them.

use utopia_http::Mode;
Rust
pub enum Mode

The two server shapes: many single-request workers, or a few concurrent ones.

use utopia_http::Handler;
Rust
pub trait Handler: Send + Sync + 'static

What the server runs for each request: turns a request into a response.

Implemented byApp
use utopia_http::serve;
Rust
pub async fn serve<H, S>(addr: SocketAddr, handler: Arc<H>, options: ServerOptions, shutdown: S) -> std::io::Result<()> where H: Handler, S: Future<Output = ()> + Send,

Serves handler on addr until shutdown resolves.

use utopia_http::serve_listener;
Rust
pub async fn serve_listener<H, S>(listener: TcpListener, handler: Arc<H>, options: ServerOptions, shutdown: S) -> std::io::Result<()> where H: Handler, S: Future<Output = ()> + Send,

Serves handler on a bound listener until shutdown resolves.