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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
pub(crate) mod account_manager;
pub(crate) mod beginners;
pub(crate) mod gateway_manager;
pub(crate) mod guest_manager;
pub(crate) mod subscriptions_manager;
pub(crate) mod system_manager;
pub(crate) mod tenant_manager;
pub(crate) mod tenant_owner;
pub(crate) mod users_manager;
use super::shared::{insert_role_header, UrlGroup};
use account_manager::{
guest_endpoints as account_manager_guest_endpoints,
guest_role_endpoints as account_manager_guest_role_endpoints,
};
use actix_web::{dev::Service, web};
use beginners::{
account_endpoints as beginners_account_endpoints,
guest_user_endpoints as beginners_guest_user_endpoints,
meta_endpoints as beginners_meta_endpoints,
profile_endpoints as beginners_profile_endpoints,
tenant_endpoints as beginners_tenant_endpoints,
token_endpoints as beginners_token_endpoints,
user_endpoints as beginners_user_endpoints,
};
use gateway_manager::{
route_endpoints as gateway_manager_route_endpoints,
service_endpoints as gateway_manager_service_endpoints,
tools_endpoints as gateway_manager_tools_endpoints,
};
use guest_manager::guest_role_endpoints as guest_manager_guest_role_endpoints;
use myc_core::domain::actors::SystemActor;
use subscriptions_manager::{
account_endpoints as subscription_manager_account_endpoints,
guest_endpoints as subscription_manager_guest_endpoints,
guest_role_endpoints as subscription_manager_guest_role_endpoints,
tag_endpoints as subscription_manager_tag_endpoints,
};
use system_manager::{
error_code_endpoints as system_manager_error_code_endpoints,
webhook_endpoints as system_manager_webhook_endpoints,
};
use tenant_manager::{
account_endpoints as tenant_manager_account_endpoints,
guest_endpoints as tenant_manager_guest_endpoints,
tag_endpoints as tenant_manager_tag_endpoints,
tenant_endpoints as tenant_manager_tenant_endpoints,
};
use tenant_owner::{
account_endpoints as tenant_owner_account_endpoints,
meta_endpoints as tenant_owner_meta_endpoints,
owner_endpoints as tenant_owner_owner_endpoints,
tenant_endpoints as tenant_owner_tenant_endpoints,
};
use users_manager::account_endpoints as user_manager_account_endpoints;
// ? ---------------------------------------------------------------------------
// ? Configure application re-routing
// ? ---------------------------------------------------------------------------
pub(crate) fn configure(config: &mut web::ServiceConfig) {
config
//
// Beginners
//
.service(
web::scope(SystemActor::Beginner.str())
//
// Configure the standard role endpoints
//
.service(
web::scope(UrlGroup::Accounts.str())
.configure(beginners_account_endpoints::configure),
)
.service(
web::scope(UrlGroup::Guests.str())
.configure(beginners_guest_user_endpoints::configure),
)
.service(
web::scope(UrlGroup::Meta.str())
.configure(beginners_meta_endpoints::configure),
)
.service(
web::scope(UrlGroup::Profile.str())
.configure(beginners_profile_endpoints::configure),
)
.service(
web::scope(UrlGroup::Tenants.str())
.configure(beginners_tenant_endpoints::configure),
)
.service(
web::scope(UrlGroup::Tokens.str())
.configure(beginners_token_endpoints::configure),
)
.service(
web::scope(UrlGroup::Users.str())
.configure(beginners_user_endpoints::configure),
),
)
//
// Gateway Managers
//
.service(
web::scope(SystemActor::GatewayManager.str())
//
// Inject a header to be collected by the MyceliumProfileData
// extractor.
//
// Endpoints restricted to users with the role:
// - GatewayManager
//
.wrap_fn(|req, srv| {
let req = insert_role_header(
req,
vec![SystemActor::GatewayManager],
);
srv.call(req)
})
//
// Configure the standard role endpoints
//
.service(
web::scope(UrlGroup::Routes.str())
.configure(gateway_manager_route_endpoints::configure),
)
.service(
web::scope(UrlGroup::Services.str()).configure(
gateway_manager_service_endpoints::configure,
),
)
.service(
web::scope(UrlGroup::Tools.str())
.configure(gateway_manager_tools_endpoints::configure),
),
)
//
// Guest Managers
//
.service(
web::scope(SystemActor::GuestsManager.str())
//
// Inject a header to be collected by the MyceliumProfileData
// extractor.
//
// Endpoints restricted to users with the role:
// - GuestManager
//
.wrap_fn(|req, srv| {
let req = insert_role_header(
req,
vec![SystemActor::GuestsManager],
);
srv.call(req)
})
//
// Configure the standard role endpoints
//
.service(
web::scope(UrlGroup::GuestRoles.str()).configure(
guest_manager_guest_role_endpoints::configure,
),
),
)
//
// Subscription Managers
//
.service(
web::scope(SystemActor::SubscriptionsManager.str())
//
// Inject a header to be collected by the MyceliumProfileData
// extractor.
//
// Endpoints restricted to users with the role:
// - TenantOwner
// - TenantManager
// - SubscriptionsManager
//
.wrap_fn(|req, srv| {
let req = insert_role_header(
req,
vec![
SystemActor::TenantManager,
SystemActor::SubscriptionsManager,
],
);
srv.call(req)
})
//
// Configure the standard role endpoints
//
.service(web::scope(UrlGroup::Accounts.str()).configure(
subscription_manager_account_endpoints::configure,
))
.service(
web::scope(UrlGroup::Tags.str()).configure(
subscription_manager_tag_endpoints::configure,
),
)
.service(
web::scope(UrlGroup::Guests.str()).configure(
subscription_manager_guest_endpoints::configure,
),
)
.service(web::scope(UrlGroup::GuestRoles.str()).configure(
subscription_manager_guest_role_endpoints::configure,
)),
)
//
// Account Managers
//
.service(
web::scope(SystemActor::AccountManager.str())
//
// Inject a header to be collected by the MyceliumProfileData
// extractor.
//
// Endpoints restricted to users with the role:
// - AccountManager
//
//.wrap_fn(|req, srv| {
// let req = insert_role_header(
// req,
// vec![SystemActor::AccountManager],
// );
// srv.call(req)
//})
//
// Configure the standard role endpoints
//
.service(
web::scope(UrlGroup::Guests.str())
.configure(account_manager_guest_endpoints::configure),
)
.service(web::scope(UrlGroup::GuestRoles.str()).configure(
account_manager_guest_role_endpoints::configure,
)),
)
//
// System Managers
//
.service(
web::scope(SystemActor::SystemManager.str())
//
// Inject a header to be collected by the MyceliumProfileData
// extractor.
//
// Endpoints restricted to users with the role:
// - SystemManager
//
.wrap_fn(|req, srv| {
let req = insert_role_header(
req,
vec![SystemActor::SystemManager],
);
srv.call(req)
})
//
// Configure the standard role endpoints
//
.service(
web::scope(UrlGroup::ErrorCodes.str()).configure(
system_manager_error_code_endpoints::configure,
),
)
.service(
web::scope(UrlGroup::Webhooks.str())
.configure(system_manager_webhook_endpoints::configure),
),
)
//
// Tenant Manager
//
.service(
web::scope(SystemActor::TenantManager.str())
//
// Inject a header to be collected by the MyceliumProfileData
// extractor.
//
// Endpoints restricted to users with the role:
// - TenantOwner
// - TenantManager
//
.wrap_fn(|req, srv| {
let req = insert_role_header(
req,
vec![SystemActor::TenantManager],
);
srv.call(req)
})
//
// Configure the standard role endpoints
//
.service(
web::scope(UrlGroup::Accounts.str())
.configure(tenant_manager_account_endpoints::configure),
)
.service(
web::scope(UrlGroup::Guests.str())
.configure(tenant_manager_guest_endpoints::configure),
)
.service(
web::scope(UrlGroup::Tags.str())
.configure(tenant_manager_tag_endpoints::configure),
)
.service(
web::scope(UrlGroup::Tenants.str())
.configure(tenant_manager_tenant_endpoints::configure),
),
)
//
// Tenant Owner
//
.service(
web::scope(SystemActor::TenantOwner.str())
//
// Configure the standard role endpoints
//
.service(
web::scope(UrlGroup::Accounts.str())
.configure(tenant_owner_account_endpoints::configure),
)
.service(
web::scope(UrlGroup::Meta.str())
.configure(tenant_owner_meta_endpoints::configure),
)
.service(
web::scope(UrlGroup::Owners.str())
.configure(tenant_owner_owner_endpoints::configure),
)
.service(
web::scope(UrlGroup::Tenants.str())
.configure(tenant_owner_tenant_endpoints::configure),
),
)
//
// User Accounts Managers
//
.service(
web::scope(SystemActor::UsersManager.str())
//
// Inject a header to be collected by the MyceliumProfileData
// extractor.
//
// Endpoints restricted to users with the role:
// - UsersManager
//
.wrap_fn(|req, srv| {
let req = insert_role_header(
req,
vec![SystemActor::UsersManager],
);
srv.call(req)
})
//
// Configure the standard role endpoints
//
.service(
web::scope(UrlGroup::Accounts.str())
.configure(user_manager_account_endpoints::configure),
),
);
}