Crate poem[][src]

Expand description

Poem is a full-featured and easy-to-use web framework with the Rust programming language.

Usage

Depend on poem in Cargo.toml:

poem = "*"

Example

use poem::{handler, route, web::Path, Server};

#[handler(method = "get")]
async fn hello(Path(name): Path<String>) -> String {
    format!("hello: {}", name)
}

#[tokio::main]
async fn main() {
    let app = route().at("/hello/:name", hello);
    let server = Server::bind("127.0.0.1:3000").await.unwrap();
    server.run(app).await.unwrap();
}

Features

To avoid compiling unused dependencies, Poem gates certain features, all of which are disabled by default:

FeatureDescription
websocketSupport for WebSocket
multipartSupport for Multipart
sseSupport Server-Sent Events (SSE)
tlsSupport for HTTP server over TLS
typed-headersSupport for typed-headers
tracingSupport for Tracing middleware
tempfileSupport for tempfile

Re-exports

pub use error::Error;
pub use error::Result;
pub use guard::Guard;
pub use middleware::Middleware;
pub use route::route;
pub use web::FromRequest;
pub use web::IntoResponse;
pub use web::RequestBody;

Modules

Endpoint related types.

Some common error types.

Route match guards.

A general purpose library of common HTTP types

Commonly used middleware.

Route object and DSL

Some commonly used services that implement Endpoint.

Commonly used as the type of extractor or response.

Structs

A body object for requests and responses.

Represents an HTTP request.

An request builder.

Represents an HTTP response.

An response builder.

An HTTP Server.

An HTTP Server over TLS.

Traits

An HTTP request handler.

Extension trait for Endpoint.

Functions

Create an endpoint with a function.

Attribute Macros

Wrap an asynchronous function as an Endpoint.