Poem

Set up debugger in a Rust project using the Poem framework.

Last updated March 19, 2026

Rust + Poem

This guide covers adding debugger to a Rust API using Poem.

Poem official docs

Feature Support
Server console Yes
Server errors Via tracing
HTTP requests Yes
Browser script injection Manual

Prerequisites

  • Rust 1.75 or later

Install

Add the crate to your Cargo.toml:

[dependencies]
ephem-debugger = { version = "0.1", features = ["poem"] }

Set up

use poem::{Route, Server, get, handler, listener::TcpListener};
use ephem_debugger::poem_middleware;
use tracing_subscriber::prelude::*;

#[handler]
fn index() -> &'static str { "hello" }

#[tokio::main]
async fn main() {
    let (middleware, capture_layer) = poem_middleware::layers(3000);

    tracing_subscriber::registry()
        .with(capture_layer)
        .with(tracing_subscriber::fmt::layer())
        .init();

    let app = Route::new()
        .at("/", get(index))
        .with(middleware);

    Server::new(TcpListener::bind("0.0.0.0:3000"))
        .run(app)
        .await
        .unwrap();
}

Verify

cargo run
npx dbg status
pnpm dlx dbg status
bun x dbg status
yarn dlx dbg status
npx dbg server console
pnpm dlx dbg server console
bun x dbg server console
yarn dlx dbg server console

Browser support

The middleware automatically handles /_/d.js and /_/d POST routes. To enable browser capture, add these script tags before </body> in your HTML templates:

<script>window.__DEBUGGER_INGEST_URL__="/_/d";</script>
<script src="/_/d.js" defer></script>

Query browser data with:

npx dbg browser console
pnpm dlx dbg browser console
bun x dbg browser console
yarn dlx dbg browser console
npx dbg browser errors
pnpm dlx dbg browser errors
bun x dbg browser errors
yarn dlx dbg browser errors
npx dbg browser network
pnpm dlx dbg browser network
bun x dbg browser network
yarn dlx dbg browser network
npx dbg browser storage
pnpm dlx dbg browser storage
bun x dbg browser storage
yarn dlx dbg browser storage

Full example

See the complete working example at examples/rust/poem.

Search Documentation

Search for pages and content