MCPcopy Create free account
hub / github.com/clawshell/clawshell / make_app

Function make_app

src/app/tests.rs:24–83  ·  view source on GitHub ↗
(upstream_url: &str)

Source from the content-addressed store, hash-verified

22use crate::stats::Stats;
23
24fn make_app(upstream_url: &str) -> axum::Router {
25 let mut key_map = BTreeMap::new();
26 key_map.insert(
27 "vk-test-1".to_string(),
28 ResolvedKey {
29 source: KeySource::Static {
30 real_key: "sk-real-1".to_string(),
31 },
32 provider: Provider::Openai,
33 },
34 );
35 key_map.insert(
36 "vk-test-2".to_string(),
37 ResolvedKey {
38 source: KeySource::Static {
39 real_key: "sk-real-2".to_string(),
40 },
41 provider: Provider::Openai,
42 },
43 );
44
45 let patterns = vec![
46 DlpPattern {
47 name: "ssn".to_string(),
48 regex: r"\b\d{3}-\d{2}-\d{4}\b".to_string(),
49 action: DlpAction::Block,
50 },
51 DlpPattern {
52 name: "email".to_string(),
53 regex: r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b".to_string(),
54 action: DlpAction::Block,
55 },
56 DlpPattern {
57 name: "credit_card".to_string(),
58 regex: r"\b(?:\d[ -]*?){13,19}\b".to_string(),
59 action: DlpAction::Block,
60 },
61 ];
62
63 let mut upstream_urls = BTreeMap::new();
64 upstream_urls.insert(Provider::Openai, upstream_url.to_string());
65 upstream_urls.insert(Provider::Anthropic, upstream_url.to_string());
66
67 let state = AppState {
68 key_manager: Arc::new(KeyManager::new(key_map)),
69 dlp_scanner: Arc::new(DlpScanner::new(&patterns, false).unwrap()),
70 proxy_client: Arc::new(ProxyClient::with_upstream_urls(
71 upstream_urls,
72 "2023-06-01".to_string(),
73 )),
74 oauth_registry: Arc::new(OAuthRegistry::new(Default::default())),
75 email_enabled: false,
76 email_policy: None,
77 email_accounts: Arc::new(BTreeMap::new()),
78 email_service: Arc::new(EmailService::mock_disabled()),
79 stats: Arc::new(Stats::new(None)),
80 };
81

Calls 1

build_routerFunction · 0.85

Tested by

no test coverage detected