adding an await inside a handler makes the handler invalid
Closed this issue · 0 comments
samuelcolvin commented
- I have looked for existing issues (including closed) about this
Bug Report
This fails with he trait Handler<_, _> is not implemented for fn item fn(State<AppState>, axum::Json<Record>) -> impl std::future::Future<Output = &'static str> {post_batch}
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 buffer.insert(vec![record]).await.unwrap();
, it compiles fine.
If I remote the state
parameter, but still do something that requires await
inside the handler, it's fine.
Using bytes: Bytes
instead of Json
, I get the same error.
Version
0.7.5
Platform
MacOS M1