rust-axum-jwt-auth
rust-axum-jwt-auth copied to clipboard
I can't compile the code, it prompts a compilation error, could you help me?
When compiling the program, it prompts:
error[E0277]: the trait bound fn(axum::extract::State<Arc<AppState>>, axum::Json<RegisterUserSchema>) -> impl std::future::Future<Output = Result<impl IntoResponse, (axum::http::StatusCode, axum::Json<JsonValue>)>> {register_user_handler}: Handler<_, _, _>
is not satisfied
--> src/route.rs:21:43
|
21 | .route("/api/auth/register", post(register_user_handler))
| ---- ^^^^^^^^^^^^^^^^^^^^^ the trait Handler<_, _, _>
is not implemented for fn item fn(axum::extract::State<Arc<AppState>>, axum::Json<RegisterUserSchema>) -> impl std::future::Future<Output = Result<impl IntoResponse, (axum::http::StatusCode, axum::Json<JsonValue>)>> {register_user_handler}
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait Handler<T, S, B>
:
<Or<L, R, Lt, Rt, S, B> as Handler<(M, Lt, Rt), S, B>>
<IntoHandler<H, T, S, B> as Handler<T, S, B>>
<Layered<L, H, T, S, B, B2> as Handler<T, S, B2>>
<MethodRouter<S, B> as Handler<(), S, B>>
have you tried changing impl IntoResponse to UserResponse?
I got this error previously you might need to change the order of your parameters in register_user_handler Try to derive Serialize at your RegisterUserSchema struct. Also ensure that you implement the Handler trait correctly and that the types align with how Axum expects handlers to be structured