Attribute Macro axum_debug::debug_handler [−][src]
#[debug_handler]Expand description
Generates better error messages when applied to a handler function.
Examples
Function is not async:
ⓘ
#[debug_handler]
fn handler() -> &'static str {
    "Hello, world"
}error: handlers must be async functions
  --> main.rs:xx:1
   |
xx | fn handler() -> &'static str {
   | ^^Wrong return type:
ⓘ
#[debug_handler]
async fn handler() -> bool {
    false
}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`Wrong extractor:
ⓘ
#[debug_handler]
async fn handler(a: bool) -> String {
    format!("Can I extract a bool? {}", a)
}error[E0277]: the trait bound `bool: FromRequest` is not satisfied
  --> main.rs:xx:21
   |
xx | async fn handler(a: bool) -> String {
   |                     ^^^^
   |                     |
   |                     the trait `FromRequest` is not implemented for `bool`Too many extractors:
ⓘ
#[debug_handler]
async fn handler(
    a: String,
    b: String,
    c: String,
    d: String,
    e: String,
    f: String,
    g: String,
    h: String,
    i: String,
    j: String,
    k: String,
    l: String,
    m: String,
    n: String,
    o: String,
    p: String,
    q: String,
) {}error: too many extractors. 16 extractors are allowed
note: you can nest extractors like "a: (Extractor, Extractor), b: (Extractor, Extractor)"
  --> main.rs:xx:5
   |
xx | /     a: String,
xx | |     b: String,
xx | |     c: String,
xx | |     d: String,
...  |
xx | |     p: String,
xx | |     q: String,
   | |______________^Future is not Send:
ⓘ
#[debug_handler]
async fn handler() {
    let not_send = std::rc::Rc::new(());
    async{}.await;
}error: future cannot be sent between threads safely
  --> main.rs:xx:10
   |
xx | async fn handler() {
   |          ^^^^^^^
   |          |
   |          future returned by `handler` is not `Send`