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.7"
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§

endpoints
Pre-defined endpoints.
middleware
Pre-defined middleware.
ssesse
Async SSE.

Structs§

Body
A stream of Bytes, used when receiving bodies.
Cookiecookie
Representation of an HTTP cookie.
CookieBuildercookie
Structure that follows the builder pattern for building Cookie structs.
CookieJarcookie
A collection of cookies that tracks its modifications.
DataStream
The data stream of a body.
DataTransfer
Information about a data transfer. This is the result of DataStream::into, and provides information about the state of the stream after the transfer.
Path
A description of a path in the router.
RemoteAddress
A type that helps retrieve the remote address of a request.
Request
Represents an HTTP request.
Response
An HTTP response.
Router
An HTTP router.

Enums§

FromFormErrorfrom_form
The error type for parsing a form.
UnderError
Errors generated specifically from this library, and not its interactions user code.

Traits§

Endpoint
An HTTP request handler.
FragmentSelect
A trait used to implement path fragment retrieval.
FromFormfrom_form
A trait for types that can be created from a form.
FromFormMultiplefrom_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.
HttpEntity
A HTTP Entity.
IntoResponse
Converts the current type into a crate::Response.

Functions§

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

Type Aliases§

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

Derive Macros§

FromForm
Automatically derive FromForm from a struct.