Skip to main content

Crate ngrok_axum

Crate ngrok_axum 

Source
Expand description

Serve an Axum app through an ngrok tunnel with one call.

axum::Server was removed in axum 0.7, which broke the one-liner ngrok-rust used to offer (see https://github.com/ngrok/ngrok-rust/issues/136). The fix upstream was to replace the example with a ~30-line manual connection-serving loop, not to restore a one-liner. serve is that restored one-liner.

use axum::{routing::get, Router};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let app = Router::new().route("/", get(|| async { "hello" }));
    ngrok_axum::serve(app, ngrok_axum::Config::default()).await?;
    Ok(())
}

Structs§

Config
Configuration for a single ngrok endpoint.
Endpoint
One app bound to one endpoint, for serve_many. The same Router can be cloned across multiple Endpoints to pool one app behind several listeners.

Enums§

Binding
Ingress binding for the endpoint. Not part of ngrok’s Traffic Policy — confirmed by checking the Traffic Policy actions reference directly, so this stays a standalone field rather than folded into traffic_policy.

Functions§

serve
Opens a single ngrok HTTP endpoint per config and serves app on it. Shorthand for the one-endpoint case of serve_many.
serve_many
Opens one ngrok HTTP endpoint per entry in endpoints, all on a single session, and serves each endpoint’s app concurrently until every listener closes or a connection-level error occurs.