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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
extern crate proc_macro;
use crateroute_file_impl;
use auth_file_impl;
use empty_file_impl;
use gen_dist_impl;
use TokenStream;
use scope_impl;
///
/// Clear the specified resource file
///
/// Examples
///```text
/// #[empty_file(filename="./resources/route")]
/// pub fn empty() {
/// println!("empty route file")
/// }
///```
///
///
/// Configure the path of the routing resource file to generate the routing table
///
/// Examples
///```text
/// #[route_file(filename="./resources/route")]
/// pub fn empty() {
/// println!("empty route file")
/// }
///```
///
///
/// Build and generate a static resource directory
///
/// Examples
///```text
/// #[gen_dist(zip = "./resources/dist.zip", target_dir = "./resources")]
/// pub fn dist() {}
///```
///
///
/// Build and generate the scope function
///
/// Examples
///```text
/// #[scope(file = "./src/app/controllers/test2.rs")]
/// pub fn routes(cfg: &mut web::ServiceConfig) {
/// let scope = web::scope("/test2");
/// cfg.service(scope);
/// }
///```
/// Generate Code
///```text
/// pub fn routes(cfg: &mut web::ServiceConfig) {
/// let scope = web::scope("/test2");
/// let scope = scope.service(web::resource("/post").app_data(r#"{"method":"post","path":"/post","tag":"src::app::controllers::test2::post","desc":"post","middleware":"","auth":"true"}"#.to_string()).route(web::post().to(post)));
/// let scope = scope.service(web::resource("/get").app_data(r#"{"method":"get","path":"/get","tag":"src::app::controllers::test2::get","desc":"get","middleware":"","auth":"true"}"#.to_string()).route(web::get().to(get)));
/// let scope = scope.service(web::resource("/put").app_data(r#"{"method":"put","path":"/put","tag":"src::app::controllers::test2::put","desc":"put","middleware":"","auth":"true"}"#.to_string()).route(web::put().to(put)));
/// let scope = scope.service(web::resource("/delete").app_data(r#"{"method":"delete","path":"/delete","tag":"src::app::controllers::test2::delete","desc":"delete","middleware":"","auth":"true"}"#.to_string()).route(web::delete().to(delete)));
/// let scope = scope.service(web::resource("/head").app_data(r#"{"method":"head","path":"/head","tag":"src::app::controllers::test2::head","desc":"head","middleware":"","auth":"true"}"#.to_string()).route(web::head().to(head)));
/// cfg.service(scope);
/// }
///```
///
///
/// Sample POST request
///
/// Introduction to Parameters
/// ```text
/// path: request url path.
/// tag: The unique label of the function.
/// middleware: Middleware, with multiple configurations separated by commas.
/// desc: The description of a function.
/// auth: Whether it is authenticated or not, Default "true".
/// ```
///
/// Examples
///```text
///#[post(path = "/post", desc = "post")]
///async fn post(req: actix_web::HttpRequest) -> impl Responder {
/// success_respond_to(&req, Some(String::from("Hey post!")))
///}
///```
///
// https://rust.biofan.org/crates/attributes.html
///
/// Sample GET request
///
/// Introduction to Parameters
/// ```text
/// path: request url path.
/// tag: The unique label of the function.
/// middleware: Middleware, with multiple configurations separated by commas.
/// desc: The description of a function.
/// auth: Whether it is authenticated or not, Default "true".
/// ```
///
/// Examples
///```text
///#[get(path = "/get", desc = "get")]
///async fn get(req: actix_web::HttpRequest) -> impl Responder {
/// success_respond_to(&req, Some(String::from("Hey get!")))
///}
///```
///
///
/// Sample PUT request
///
/// Introduction to Parameters
/// ```text
/// path: request url path.
/// tag: The unique label of the function.
/// middleware: Middleware, with multiple configurations separated by commas.
/// desc: The description of a function.
/// auth: Whether it is authenticated or not, Default "true".
/// ```
///
/// Examples
///```text
///#[put(path = "/put", desc = "put")]
///async fn put(req: actix_web::HttpRequest) -> impl Responder {
/// success_respond_to(&req, Some(String::from("Hey put!")))
///}
///```
///
///
/// Sample DELETE request
///
/// Introduction to Parameters
/// ```text
/// path: request url path.
/// tag: The unique label of the function.
/// middleware: Middleware, with multiple configurations separated by commas.
/// desc: The description of a function.
/// auth: Whether it is authenticated or not, Default "true".
/// ```
///
/// Examples
///```text
///#[delete(path = "/delete", desc = "delete")]
///async fn delete(req: actix_web::HttpRequest) -> impl Responder {
/// success_respond_to(&req, Some(String::from("Hey delete!")))
///}
///```
///
///
/// Sample HEAD request
///
/// Introduction to Parameters
/// ```text
/// path: request url path.
/// tag: The unique label of the function.
/// middleware: Middleware, with multiple configurations separated by commas.
/// desc: The description of a function.
/// auth: Whether it is authenticated or not, Default "true".
/// ```
///
/// Examples
///```text
///#[head(path = "/delete", desc = "head")]
///async fn head(req: actix_web::HttpRequest) -> impl Responder {
/// success_respond_to(&req, Some(String::from("Hey head!")))
///}
///```
///