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.
- sse
sse
- Async SSE.
Structs§
- Body
- A stream of
Bytes
, used when receiving bodies. - Cookie
cookie
- Representation of an HTTP cookie.
- Cookie
Builder cookie
- Structure that follows the builder pattern for building
Cookie
structs. - Cookie
Jar cookie
- A collection of cookies that tracks its modifications.
- Data
Stream - The data stream of a body.
- Data
Transfer - 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.
- Remote
Address - 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§
- From
Form Error from_form
- The error type for parsing a form.
- Under
Error - Errors generated specifically from this library, and not its interactions user code.
Traits§
- Endpoint
- An HTTP request handler.
- Fragment
Select - A trait used to implement path fragment retrieval.
- From
Form from_form
- A trait for types that can be created from a form.
- From
Form Multiple from_form
- A trait for types that can be created from a form.
- From
Form Value from_form
- A trait for types that can be created from a form.
- Http
Entity - A HTTP Entity.
- Into
Response - 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§
- From
Form - Automatically derive
FromForm
from a struct.