Axum custom request extractor and validator using FromRequest

This post documents what I learned about creating custom Axum extractor which can be used with the validator for validation. Create a new test project: ➜ cargo new request-validator cd request-validator The first crate to be added is axum for Axum framework. request-validator on  main [?] via 🦀 v1.79.0 ➜ cargo add axum Updating crates.io index Adding axum v0.7.5 to dependencies Features: + form + http1 + json + matched-path + original-uri + query + tokio + tower-log + tracing - __private_docs - http2 - macros - multipart - ws Updating crates....

July 12, 2024 · 5 min · 988 words · kenno

Rust cannot find derive macro `Serialize` in this scope

While trying out some Rust exercises, I came across the following error: $ cargo run --bin iter2 Compiling tutor-web-app-ssr v0.1.0 (/home/kenno/dev/rust/chapter7/ezytutors/tutor-web-app-ssr) error: cannot find derive macro `Serialize` in this scope --> tutor-web-app-ssr/src/bin/iter2.rs:17:10 | 17 | #[derive(Serialize, Deserialize)] | ^^^^^^^^^ | note: `Serialize` is imported here, but it is only a trait, without a derive macro --> tutor-web-app-ssr/src/bin/iter2.rs:5:26 | 5 | use serde::{Deserialize, Serialize}; | ^^^^^^^^^ error: cannot find derive macro `Deserialize` in this scope --> tutor-web-app-ssr/src/bin/iter2....

May 22, 2024 · 1 min · 157 words · kenno