TEMPLATE_MAIN

Constant TEMPLATE_MAIN 

Source
pub const TEMPLATE_MAIN: &str = r#"use axum::{routing::get, Router};

async fn ping() -> &'static str {
    "pong"
}

#[tokio::main]
async fn main() {
    let _ = serde_json::json!({"ok": true});
    let _v: tower::ServiceBuilder<tower::layer::util::Identity> = tower::ServiceBuilder::new();
    let app = Router::new().route("/ping", get(ping));
    let port: u16 = std::env::var("METRALE_HARNESS_PORT")
        .unwrap_or_else(|_| "3001".to_string())
        .parse()
        .unwrap();
    let listener = tokio::net::TcpListener::bind(("0.0.0.0", port)).await.unwrap();
    axum::serve(listener, app).await.unwrap();
}
"#;
Expand description

2026-09-26: The template’s main.rs, a ping/pong server on METRALE_HARNESS_PORT; the same text as the main.rs heredoc in warm_cargo_cache.sh after its first comment line (asserted in the tests).