actix-web
actix-web copied to clipboard
Extract path segment struct flattening
Expected Behavior
Structs should implement something along the lines of serde's #[serde(flatten)]
in order to allow nested structs (for usage with extract path segment structs). Example:
#[route("/{username}/{repository}/tree/{tree}/blob/{blob:.*}", method = "GET")]
pub(crate) async fn view_blob(uri: web::Path<BlobRequest>) -> Result<impl Responder> {}
#[derive(Deserialize)]
pub(crate) struct GitRequest {
pub(crate) username: String,
pub(crate) repository: String
}
#[derive(Deserialize)]
pub(crate) struct BlobRequest {
#[serde(flatten)]
pub(crate) repo: GitRequest,
pub(crate) tree: String,
pub(crate) blob: String
}
Current Behavior
Currently this fails with unsupported type: any
Context
This would help me reduce repeated code such as it is currently present in GitArena.
Is this still planned/any workarounds? This feature would be awesome to reduce loads of duplicate code.