1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Implement poem FromRequest to deserialize struct from query string.
//!
//! #### Example
//! ```no_run
//! use poem_queryext::QueryExtN;
//! use poem_openapi::{payload::PlainText, OpenApi};
//! use serde::Deserialize;
//!
//! struct Api;
//!
//! #[OpenApi]
//! impl Api {
//! //test url: /test?name=cx
//! //test url: /test?name=cx&age=18&hobby[0]=music&hobby[1]=game
//! #[oai(path = "/test", method = "get")]
//! async fn test(&self, QueryExtN(query): QueryExtN<QueryObj>) -> PlainText<String> {
//! PlainText(format!(
//! "name:{},age:{},hobby:{}",
//! query.name,
//! query.age.unwrap_or_default(),
//! query.hobby.unwrap_or_default().join(",")
//! ))
//! }
//! }
//!
//! #[derive(Deserialize)]
//! #[serde(rename_all = "camelCase")]
//! struct QueryObj{
//! name:String,//if want use &str,use Arc<str> or Cow<'_,str>
//! age:Option<i8>,//Non mandatory fields use Option<T>
//! hobby:Option<Vec<String>>//Non mandatory fields use Option<T>
//! }
//!
//! ```
pub use QueryExt;
pub use QueryExtN;