1use std::collections::HashMap;
2
3#[derive(Debug, Clone)]
5pub struct CommonConfig {
6 pub service_name: String,
8 pub log_level: String,
10 pub cors_allowed_origins: Vec<String>,
12 pub cors_allowed_headers: Vec<String>,
14 pub custom: HashMap<String, String>,
16}
17
18impl Default for CommonConfig {
19 fn default() -> Self {
20 Self {
21 service_name: "blinq-service".to_string(),
22 log_level: "info".to_string(),
23 cors_allowed_origins: vec!["*".to_string()],
24 cors_allowed_headers: vec!["*".to_string()],
25 custom: HashMap::new(),
26 }
27 }
28}
29
30impl CommonConfig {
31 pub fn new(service_name: impl Into<String>) -> Self {
33 Self {
34 service_name: service_name.into(),
35 ..Default::default()
36 }
37 }
38
39 pub fn with_log_level(mut self, level: impl Into<String>) -> Self {
41 self.log_level = level.into();
42 self
43 }
44
45 pub fn with_cors_origins(mut self, origins: Vec<String>) -> Self {
47 self.cors_allowed_origins = origins;
48 self
49 }
50
51 pub fn with_cors_headers(mut self, headers: Vec<String>) -> Self {
53 self.cors_allowed_headers = headers;
54 self
55 }
56
57 pub fn with_custom(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
59 self.custom.insert(key.into(), value.into());
60 self
61 }
62}