Skip to main content

run_handler

Function run_handler 

Source
async fn run_handler(
    route: &str,
    handler: impl Future<Output = Result<(StatusCode, Json<Value>)>>,
) -> (StatusCode, Json<Value>)
Expand description

Runs a request handler, turning a panic or an error into a 500 response for the caller that triggered it.

Iroh requests are spawned on the gateway’s root task group, so a panic escaping a handler trips the task group’s panic guard and shuts the whole gateway down. The HTTP path does not need this: axum::serve spawns its connection tasks outside any task group, so a panic there only drops that one connection.

A failing handler has to be answered as well: propagating the error would end the connection’s request loop, leaving the caller with a closed stream and no response at all. Like the HTTP path, the response body carries no details about the failure, since callers are unauthenticated.