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.
| 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 statuspnpm dlx dbg statusbun x dbg statusyarn dlx dbg statusnpx dbg server consolepnpm dlx dbg server consolebun x dbg server consoleyarn dlx dbg server consoleBrowser 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.



