use artisan::{Artful, Config, HttpOptions};
use serde_json::json;
use std::collections::HashMap;
#[tokio::main]
async fn main() {
Artful::config(Config::default());
let config_with_http = Config {
http: HttpOptions {
timeout: Some(10),
connect_timeout: Some(5),
..Default::default()
},
..Default::default()
};
Artful::config(config_with_http);
let mut extra = HashMap::new();
extra.insert(
"alipay".to_string(),
json!({
"app_id": "2016082000295641",
"notify_url": "https://example.com/alipay/notify",
}),
);
extra.insert(
"wechat".to_string(),
json!({
"mch_id": "1234567890",
"notify_url": "https://example.com/wechat/notify",
}),
);
let config_with_extra = Config {
extra,
http: HttpOptions {
timeout: Some(5),
connect_timeout: Some(3),
..Default::default()
},
..Default::default()
};
Artful::config(config_with_extra);
let global_config = Artful::get_config();
println!("HTTP timeout: {:?}", global_config.http.timeout);
if let Some(alipay) = global_config.extra.get("alipay") {
println!("Alipay config: {}", alipay);
}
println!("Config initialized successfully!");
}