adding an await inside a handler makes the handler invalid #2715
-
Bug ReportThis fails with async fn post_batch(
State(state): State<AppState>,
Json(record): Json<Record>,
) -> &'static str {
dbg!(&record);
let mut buffer = state.buffer.lock().expect("buffer lock");
buffer.insert(vec![record]).await.unwrap();
"ok"
} but if I comment out If I remote the Using Version
PlatformMacOS M1 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
-
To get better error messages add debug_handler In Cargo.toml axum = { version = "0.7.5", features = ["macros"] } #[axum::debug_handler]
async fn post_batch(
State(state): State<AppState>,
Json(record): Json<Record>,
) -> &'static str {
dbg!(&record);
let mut buffer = state.buffer.lock().expect("buffer lock");
buffer.insert(vec![record]).await.unwrap();
"ok"
} |
Beta Was this translation helpful? Give feedback.
See Debugging handler type errors.