forked from notgull/smol-axum
Integrations between
smol and axum
- Rust 100%
| .woodpecker | ci: Update CI pipelines to Woodpecker v3 | |
| examples | Documentation | |
| src | breaking: Add Sync bound to executor | |
| .gitignore | Initial commit | |
| Cargo.lock | chore(deps): update rust crate async-executor to v1.14.0 | |
| Cargo.toml | v0.2.1 | |
| CHANGELOG.md | v0.2.1 | |
| LICENSE-APACHE | Documentation | |
| LICENSE-MIT | Documentation | |
| README.md | Documentation | |
| renovate.json | chore: Configure Renovate | |
smol-axum
Integrations between smol and axum.
By default, axum only supports the tokio runtime. This crate adds a serve
function that can be used with smol's networking types.
Examples
useasync_io::Async;useaxum::{response::Html,routing::get,Router};usemacro_rules_attribute::apply;usestd::io;usestd::net::TcpListener;usestd::sync::Arc;#[apply(smol_macros::main!)]asyncfn main(ex: &Arc<smol_macros::Executor<'_>>)-> io::Result<()>{// Build our application with a route.
letapp=Router::new().route("/",get(handler));// Create a `smol`-based TCP listener.
letlistener=Async::<TcpListener>::bind(([127,0,0,1],3000)).unwrap();println!("listening on {}",listener.get_ref().local_addr().unwrap());// Run it using `smol_axum`
smol_axum::serve(ex.clone(),listener,app).await}asyncfn handler()-> Html<&'staticstr>{Html("<h1>Hello, World!</h1>")}License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.