mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-26 00:00:23 +02:00
* add axum-debug to workspace * update readme * add changes to changelog * little docs update * fix the gap a tab has leaked into workspace Cargo.toml, it must be fixed * address clippy warnings
64 lines
1.7 KiB
Markdown
64 lines
1.7 KiB
Markdown
[](https://choosealicense.com/licenses/mit/)
|
|
[](https://crates.io/crates/axum-debug)
|
|
[](https://docs.rs/axum-debug/)
|
|
|
|
# axum-debug
|
|
|
|
This is a debugging crate that provides better error messages for [`axum`]
|
|
framework.
|
|
|
|
[`axum`] is a great framework for developing web applications. But when you
|
|
make a mistake, error messages can be really complex and long. It can take a
|
|
long time for you to figure out what is wrong in your code. This crate provides
|
|
utilities to generate better error messages in case you make a mistake.
|
|
|
|
## Usage Example
|
|
|
|
Will fail with a better error message:
|
|
|
|
```rust
|
|
use axum::{routing::get, Router};
|
|
use axum_debug::debug_handler;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let app = Router::new().route("/", get(handler));
|
|
|
|
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
|
|
.serve(app.into_make_service())
|
|
.await
|
|
.unwrap();
|
|
}
|
|
|
|
#[debug_handler]
|
|
async fn handler() -> bool {
|
|
false
|
|
}
|
|
```
|
|
|
|
Error message:
|
|
|
|
```
|
|
error[E0277]: the trait bound `bool: IntoResponse` is not satisfied
|
|
--> main.rs:xx:23
|
|
|
|
|
xx | async fn handler() -> bool {
|
|
| ^^^^
|
|
| |
|
|
| the trait `IntoResponse` is not implemented for `bool`
|
|
```
|
|
|
|
## Safety
|
|
|
|
This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust.
|
|
|
|
## Performance
|
|
|
|
Macros in this crate have no effect when using release profile. (eg. `cargo build --release`)
|
|
|
|
## License
|
|
|
|
This project is licensed under the [MIT license](LICENSE).
|
|
|
|
[`axum`]: https://crates.io/crates/axum
|