Configs2026年7月18日·1 分钟阅读

Poem — Full-Featured Async Web Framework for Rust

A fast and elegant Rust web framework with built-in OpenAPI generation, middleware, and session management powered by Tokio and Hyper.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Poem Rust Web Framework
直接安装命令
npx -y tokrepo@latest install 949ba1c9-82e9-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Poem is a full-featured async web framework for Rust that prioritizes developer ergonomics without sacrificing performance. Built on Tokio and Hyper, it provides extractors, middleware, OpenAPI spec generation, and WebSocket support in a single cohesive package — filling the gap between minimalist frameworks and heavy enterprise stacks.

What Poem Does

  • Routes HTTP requests to async handler functions with type-safe extractors
  • Generates OpenAPI 3.0 documentation from code annotations automatically
  • Provides middleware for logging, CORS, compression, rate limiting, and auth
  • Supports WebSocket, SSE (Server-Sent Events), and multipart uploads
  • Integrates with Tower middleware ecosystem for reuse

Architecture Overview

Poem uses a layered architecture: a Router dispatches requests to Endpoints (handlers). Extractors pull typed data from requests (path params, query strings, JSON bodies). Middleware wraps endpoints for cross-cutting concerns. The OpenAPI module uses proc macros to derive schema definitions from Rust types at compile time, producing a spec without runtime reflection.

Self-Hosting & Configuration

  • Add to Cargo.toml: poem = "3" and poem-openapi = "5"
  • Define routes with method-specific macros (get, post, put, delete)
  • Configure TLS via poem with rustls or native-tls feature flags
  • Deploy as a single static binary — no runtime dependencies
  • Use tracing integration for structured logging

Key Features

  • Compile-time OpenAPI spec generation from handler signatures
  • Type-safe parameter extraction with helpful compile errors
  • Built-in session management with cookie and Redis backends
  • First-class WebSocket support with typed messages
  • Graceful shutdown handling for zero-downtime deploys

Comparison with Similar Tools

  • Axum — Also Tokio-based, more minimal; Poem has built-in OpenAPI and sessions
  • Actix Web — Higher raw throughput; Poem offers better ergonomics and compile times
  • Rocket — Synchronous by default (v0.5 adds async); Poem is async-first
  • Warp — Filter-based composition; Poem uses more traditional routing patterns

FAQ

Q: How does Poem compare to Axum in performance? A: Both use Hyper/Tokio and have nearly identical throughput. The difference is in API surface — Poem bundles more features while Axum is more composable.

Q: Can I use Poem with SQLx or Diesel? A: Yes. Pass a database pool as shared state via Data extractor, then use it in any handler.

Q: Does Poem support gRPC? A: Not directly. Use tonic alongside Poem, or route gRPC traffic separately. Poem focuses on HTTP/REST and WebSocket.

Q: How mature is Poem for production use? A: Poem is stable with semantic versioning. It powers production services handling high request volumes. The ecosystem is smaller than Actix or Axum but growing.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产