Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebpuetz/axum-convenience
https://github.com/sebpuetz/axum-convenience
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sebpuetz/axum-convenience
- Owner: sebpuetz
- Created: 2022-01-06T22:00:01.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-09T16:31:13.000Z (almost 3 years ago)
- Last Synced: 2024-04-19T19:03:15.361Z (7 months ago)
- Language: Rust
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Axum app wrapper
**Under development**
This crate is supposed to bring some convenience wrappers for `axum`.
Currently there are very few conveniences available, one of them is a configurable shutdown
listener that either waits for signals or for the completion of a provided future.Another one is encapsulation of a running server in the `App` struct which offers an API to
retrieve the local address of the bound socket.Internally, the crate uses [axum_server](https://github.com/programatik29/axum-server/) to serve
application.I'd like to offer some easy to enable middleware layers that e.g. aggregate metrics like latencies
per endpoint.# Example
```rust
use axum::Router;
use axum::routing::get;
use axum_convenience::{App, ShutdownSignal};let router = Router::new().route(
"/hello-world",
get::<_, _, Body>(|| async { "hello world" }),
);let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
let app = App::builder(addr, router)
.with_graceful_shutdown(ShutdownSignal::OsSignal)
.spawn();println!("App listening at {}, waiting for shutdown signal", app.local_addr());
app.await?;
```