rust-axum-jwt-auth icon indicating copy to clipboard operation
rust-axum-jwt-auth copied to clipboard

I can't compile the code, it prompts a compilation error, could you help me?

Open eyes4 opened this issue 1 year ago • 1 comments

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>>

eyes4 avatar Nov 16 '23 15:11 eyes4

have you tried changing impl IntoResponse to UserResponse?

henningcullin avatar Feb 20 '24 21:02 henningcullin

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

TemaDeveloper avatar Oct 09 '24 04:10 TemaDeveloper