systemprompt_extension/
router.rs1#[derive(Debug, Clone, Copy)]
2pub struct ExtensionRouterConfig {
3 pub base_path: &'static str,
4 pub requires_auth: bool,
5}
6
7impl ExtensionRouterConfig {
8 #[must_use]
9 pub const fn new(base_path: &'static str) -> Self {
10 Self {
11 base_path,
12 requires_auth: true,
13 }
14 }
15
16 #[must_use]
17 pub const fn public(base_path: &'static str) -> Self {
18 Self {
19 base_path,
20 requires_auth: false,
21 }
22 }
23}
24
25#[derive(Debug, Clone, Copy)]
26pub struct SiteAuthConfig {
27 pub login_path: &'static str,
28 pub protected_prefixes: &'static [&'static str],
29 pub public_prefixes: &'static [&'static str],
30 pub required_scope: &'static str,
31}
32
33#[cfg(feature = "web")]
34#[derive(Debug, Clone)]
35pub struct ExtensionRouter {
36 pub router: axum::Router,
37 pub base_path: &'static str,
38 pub requires_auth: bool,
39}
40
41#[cfg(feature = "web")]
42impl ExtensionRouter {
43 #[must_use]
44 pub const fn new(router: axum::Router, base_path: &'static str) -> Self {
45 Self {
46 router,
47 base_path,
48 requires_auth: true,
49 }
50 }
51
52 #[must_use]
53 pub const fn public(router: axum::Router, base_path: &'static str) -> Self {
54 Self {
55 router,
56 base_path,
57 requires_auth: false,
58 }
59 }
60
61 #[must_use]
62 pub const fn config(&self) -> ExtensionRouterConfig {
63 ExtensionRouterConfig {
64 base_path: self.base_path,
65 requires_auth: self.requires_auth,
66 }
67 }
68}