Crate poem[][src]

Expand description

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


Depend on poem in Cargo.toml:

poem = "*"


use poem::{get, handler, listener::TcpListener, web::Path, IntoResponse, Route, Server};

fn hello(Path(name): Path<String>) -> String {
    format!("hello: {}", name)

async fn main() -> Result<(), std::io::Error> {
    let app = Route::new().at("/hello/:name", get(hello));
    let listener = TcpListener::bind("");
    let server = Server::new(listener).await?;

Crate features

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

cookieSupport for Cookie
websocketSupport for WebSocket
multipartSupport for Multipart
sseSupport Server-Sent Events (SSE)
tlsSupport for HTTP server over TLS
tempfileSupport for tempfile
tower-compatAdapters for tower::Layer and tower::Service.


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


Endpoint related types.

Some common error types.

A general purpose library of common HTTP types

Commonly used listeners.

Commonly used middleware.

Some commonly used services that implement Endpoint.

Commonly used as the type of extractor or response.


A body object for requests and responses.

Represents an HTTP request.

An request builder.

Component parts of an HTTP Request.

Represents an HTTP response.

An response builder.

Component parts of an HTTP Response.

Routing object

Routing object for HTTP methods

An HTTP Server.


An HTTP request handler.

Extension trait for Endpoint.

Represents a type that can convert into endpoint.


A helper function, similar to RouteMethod::new().connect(ep).

A helper function, similar to RouteMethod::new().delete(ep).

A helper function, similar to RouteMethod::new().get(ep).

A helper function, similar to RouteMethod::new().head(ep).

A helper function, similar to RouteMethod::new().options(ep).

A helper function, similar to RouteMethod::new().patch(ep).

A helper function, similar to RouteMethod::new().post(ep).

A helper function, similar to RouteMethod::new().put(ep).

A helper function, similar to RouteMethod::new().trace(ep).

Attribute Macros

Wrap an asynchronous function as an Endpoint.