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.3.5"
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 ::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.
The data stream of a body.
Information about a data transfer. This is the result of DataStream::into, and provides information about the state of the stream after the transfer.
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

FromFormErrorfrom_form
The error type for parsing a form.
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.
FromFormfrom_form
A trait for types that can be created from a form.
A trait for types that can be created from a form.
FromFormValuefrom_form
A trait for types that can be created from a form.
A HTTP Entity.
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.

Derive Macros

Automatically derive FromForm from a struct.