Add axum example

This commit is contained in:
Aode (lion) 2022-03-05 15:31:17 -06:00
parent 151aa09abe
commit 18e6ebf64a
2 changed files with 16 additions and 0 deletions

View file

@ -19,3 +19,6 @@ jive = { git = "https://git.asonix.dog/safe-async/jive", features = [
"tokio-io-compat",
] }
tokio = { version = "1", default-features = false }
[dev-dependencies]
axum = "0.4.8"

13
examples/axum.rs Normal file
View file

@ -0,0 +1,13 @@
async fn hello() -> &'static str {
"hewwo mr obama"
}
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
jive::block_on(async move {
let app = axum::Router::new().route("/", axum::routing::get(hello));
hyperjive::server::builder(([0, 0, 0, 0], 8080)).await?.serve(app.into_make_service()).await?;
Ok(())
})?
}