Rocket

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

Last updated March 19, 2026

Rust + Rocket

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

Rocket 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 = ["rocket"] }

Set up

use ephem_debugger::rocket_middleware;
use tracing_subscriber::prelude::*;

#[rocket::main]
async fn main() -> Result<(), rocket::Error> {
    let (fairing, capture_layer) = rocket_middleware::layers(8000);

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

    rocket::build()
        .attach(fairing)
        .mount("/", routes![index, users])
        .launch()
        .await?;
    Ok(())
}

The fairing hooks into on_liftoff (starts the IPC bridge), on_request (records start time), and on_response (captures method, path, status, duration).

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

Mount browser routes:

rocket::build()
    .attach(fairing)
    .mount("/", rocket_middleware::browser_routes())

Add script tags before </body> in your HTML templates:

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

Full example

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

Search Documentation

Search for pages and content