-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.rs
41 lines (38 loc) · 980 Bytes
/
config.rs
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
use actix_web::web;
/// Run custom configuration as part of the application building
/// process.
///
/// This function should contain all custom configuration for your function application.
///
/// ```rust
/// fn configure(cfg: &mut web::ServiceConfig) {
/// let db_driver = my_db();
/// cfg.data(db_driver.clone());
/// }
/// ```
///
/// Then you can use configured resources in your function.
///
/// ```rust
/// pub async fn index(
/// req: HttpRequest,
/// driver: web::Data<DbDriver>,
/// ) -> HttpResponse {
/// HttpResponse::NoContent()
/// }
pub fn configure(cfg: &mut web::ServiceConfig) {
log::info!("Configuring service");
cfg.data(HandlerConfig::default());
}
/// An example of the function configuration structure.
#[derive(Clone)]
pub struct HandlerConfig {
pub name: String,
}
impl Default for HandlerConfig {
fn default() -> HandlerConfig {
HandlerConfig {
name: String::from("world"),
}
}
}