INNER CODE UNIT · Rust

main

wasmCloud/wasmCloud · templates/http-api-with-distributed-workloads/http-api/src/lib.rs:18

async fn main(req: Request<Body>) -> anyhow::Result<Response<Body>> {
    match req.uri().path() {
        "/" => home(req).await,
        "/task" => create_task(req).await,
        _ => Response::builder()
            .status(StatusCode::NOT_FOUND)
            .body("Not found\n".into())
            .map_err(Into::into),
    }
}

async fn home(_req: Request<Body>) -> anyhow::Result<Response<Body>> {
    Response::builder()
        .status(StatusCode::OK)
        .header("Content-Type", "text/html")
        .body(UI_HTML.into())
        .map_err(Into::into)
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…