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.
Answered by
jplatte
Apr 18, 2024
Replies: 2 comments 1 reply
Answer selected by
samuelcolvin
-
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.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See Debugging handler type errors.