systemprompt_models/profile/
server.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct ServerConfig {
7 pub host: String,
8
9 pub port: u16,
10
11 pub api_server_url: String,
12
13 pub api_internal_url: String,
14
15 pub api_external_url: String,
16
17 #[serde(default)]
18 pub use_https: bool,
19
20 #[serde(default)]
21 pub cors_allowed_origins: Vec<String>,
22
23 #[serde(default)]
24 pub content_negotiation: ContentNegotiationConfig,
25
26 #[serde(default)]
27 pub security_headers: SecurityHeadersConfig,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct ContentNegotiationConfig {
32 #[serde(default)]
33 pub enabled: bool,
34
35 #[serde(default = "default_markdown_suffix")]
36 pub markdown_suffix: String,
37}
38
39impl Default for ContentNegotiationConfig {
40 fn default() -> Self {
41 Self {
42 enabled: false,
43 markdown_suffix: default_markdown_suffix(),
44 }
45 }
46}
47
48fn default_markdown_suffix() -> String {
49 ".md".to_string()
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct SecurityHeadersConfig {
54 #[serde(default = "default_enabled")]
55 pub enabled: bool,
56
57 #[serde(default = "default_hsts")]
58 pub hsts: String,
59
60 #[serde(default = "default_frame_options")]
61 pub frame_options: String,
62
63 #[serde(default = "default_content_type_options")]
64 pub content_type_options: String,
65
66 #[serde(default = "default_referrer_policy")]
67 pub referrer_policy: String,
68
69 #[serde(default = "default_permissions_policy")]
70 pub permissions_policy: String,
71
72 #[serde(default)]
73 pub content_security_policy: Option<String>,
74}
75
76impl Default for SecurityHeadersConfig {
77 fn default() -> Self {
78 Self {
79 enabled: true,
80 hsts: default_hsts(),
81 frame_options: default_frame_options(),
82 content_type_options: default_content_type_options(),
83 referrer_policy: default_referrer_policy(),
84 permissions_policy: default_permissions_policy(),
85 content_security_policy: None,
86 }
87 }
88}
89
90const fn default_enabled() -> bool {
91 true
92}
93
94fn default_hsts() -> String {
95 "max-age=63072000; includeSubDomains; preload".to_string()
96}
97
98fn default_frame_options() -> String {
99 "DENY".to_string()
100}
101
102fn default_content_type_options() -> String {
103 "nosniff".to_string()
104}
105
106fn default_referrer_policy() -> String {
107 "strict-origin-when-cross-origin".to_string()
108}
109
110fn default_permissions_policy() -> String {
111 "camera=(), microphone=(), geolocation=()".to_string()
112}