sentry_tunnel/
config.rs

1use serde::{Deserialize, Serialize};
2
3/// Sentry tunnel configuration
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct SentryTunnelConfig {
6    /// Sentry host address (without https://)
7    pub sentry_host: String,
8
9    /// List of allowed project IDs
10    pub allowed_project_ids: Vec<String>,
11
12    /// Custom routing path, defaults to "/tunnel"
13    #[serde(default = "default_path")]
14    pub path: String,
15
16    /// Request timeout in seconds
17    #[serde(default = "default_timeout")]
18    pub timeout_secs: u64,
19}
20
21fn default_path() -> String {
22    "/tunnel".to_string()
23}
24
25fn default_timeout() -> u64 {
26    30
27}
28
29impl SentryTunnelConfig {
30    /// Create a new configuration
31    pub fn new(sentry_host: impl Into<String>, allowed_project_ids: Vec<String>) -> Self {
32        Self {
33            sentry_host: sentry_host.into(),
34            allowed_project_ids,
35            path: default_path(),
36            timeout_secs: default_timeout(),
37        }
38    }
39
40    /// Set custom path
41    pub fn with_path(mut self, path: impl Into<String>) -> Self {
42        self.path = path.into();
43        self
44    }
45
46    /// Set timeout duration
47    pub fn with_timeout(mut self, timeout_secs: u64) -> Self {
48        self.timeout_secs = timeout_secs;
49        self
50    }
51}