Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Nov 29, 2023
1 parent 75493b5 commit 69f88bd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/core/src/extract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//! # use salvo_core::prelude::*;
//! # use serde::{Deserialize, Serialize};
//! #[derive(Serialize, Deserialize, Extractible, Debug)]
//! #[salvo(extract(default_source(from = "body", format = "json")))]
//! #[salvo(extract(default_source(from = "body")))]
//! struct GoodMan<'a> {
//! #[salvo(extract(source(from = "param")))]
//! id: i64,
Expand All @@ -46,7 +46,7 @@
//! }
//!
//! #[derive(Serialize, Deserialize, Extractible, Debug)]
//! #[salvo(extract(default_source(from = "body", format = "json")))]
//! #[salvo(extract(default_source(from = "body")))]
//! struct Nested<'a> {
//! #[salvo(extract(source(from = "param")))]
//! id: i64,
Expand Down
3 changes: 2 additions & 1 deletion crates/core/src/serde/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ impl<'de> RequestDeserializer<'de> {
while self.field_index < self.metadata.fields.len() as isize - 1 {
self.field_index += 1;
let field = &self.metadata.fields[self.field_index as usize];
self.field_flatten = field.flatten;
self.field_str_value = None;
self.field_vec_value = None;

Expand Down Expand Up @@ -656,7 +657,7 @@ mod tests {
#[tokio::test]
async fn test_de_request_with_json_str() {
#[derive(Deserialize, Extractible, Eq, PartialEq, Debug)]
#[salvo(extract(default_source(from = "body", format = "json")))]
#[salvo(extract(default_source(from = "body", parser = "json")))]
struct RequestData<'a> {
#[salvo(extract(source(from = "param")))]
p2: &'a str,
Expand Down
1 change: 1 addition & 0 deletions crates/macros/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ pub(crate) fn generate(args: DeriveInput) -> Result<TokenStream, Error> {
let ty = omit_type_path_lifetimes(ty);
nested_metadata = Some(quote! {
field = field.metadata(<#ty as #salvo::extract::Extractible>::metadata());
field = field.set_flatten(true);
});
} else {
return Err(Error::new_spanned(name, "Invalid type for request source."));
Expand Down

0 comments on commit 69f88bd

Please sign in to comment.