Crate under

source · []
Expand description

Under is a batteries-included async HTTP framework built for easy development. Under is based on Tokio, an async runtime. Under is meant to take the headache out of developing HTTP servers, while still being fairly performant.

Getting Started

To get started, just add under and tokio to your Cargo.toml:

under = "0.1.0"
tokio = { version = "1.12.0", features = ["full"] } # or whatever the latest version is

Examples

async fn hello_world(_: under::Request) -> Result<under::Response, anyhow::Error> {
    Ok(under::Response::text("hello, world!"))
}

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let mut http = under::http();
    http.at("/").get(hello_world);
    http.listen("0.0.0.0:8080").await?;
    Ok(())
}

Re-exports

pub use self::middleware::Middleware;
pub use {{root}}::http;

Modules

Pre-defined endpoints.

Pre-defined middleware.

ssesse

Async SSE.

Structs

A stream of Bytes, used when receiving bodies.

Cookiecookie

Representation of an HTTP cookie.

Structure that follows the builder pattern for building Cookie structs.

CookieJarcookie

A collection of cookies that tracks its modifications.

A description of a path in the router.

A type that helps retrieve the remote address of a request.

Represents an HTTP request.

An HTTP response.

An HTTP router.

Enums

Errors generated specifically from this library, and not its interactions user code.

Traits

An HTTP request handler.

A trait used to implement path fragment retrieval.

Converts the current type into a crate::Response.

Functions

This creates a new HTTP router. This is a shortcut for Router::default.

Type Definitions

A type alias for std::result::Result.