@@ -4,7 +4,12 @@ use std::time::Duration;
44
55use confique:: Config ;
66use trogon_nats:: { NatsAuth , NatsToken } ;
7- use trogon_std:: { BotToken , SigningSecret , WebhookSecret } ;
7+ use trogon_source_discord:: config:: DiscordBotToken ;
8+ use trogon_source_github:: config:: GitHubWebhookSecret ;
9+ use trogon_source_gitlab:: config:: GitLabWebhookSecret ;
10+ use trogon_source_linear:: config:: LinearWebhookSecret ;
11+ use trogon_source_slack:: config:: SlackSigningSecret ;
12+ use trogon_source_telegram:: config:: TelegramWebhookSecret ;
813
914#[ derive( Debug ) ]
1015pub enum ConfigError {
@@ -32,19 +37,17 @@ impl std::error::Error for ConfigError {}
3237#[ derive( Config ) ]
3338struct GatewayConfig {
3439 #[ config( nested) ]
35- server : ServerConfig ,
40+ http_server : HttpServerConfig ,
3641 #[ config( nested) ]
3742 nats : NatsConfig ,
3843 #[ config( nested) ]
3944 sources : SourcesConfig ,
4045}
4146
4247#[ derive( Config ) ]
43- struct ServerConfig {
48+ struct HttpServerConfig {
4449 #[ config( env = "TROGON_GATEWAY_PORT" , default = 8080 ) ]
4550 port : u16 ,
46- #[ config( env = "TROGON_GATEWAY_BODY_LIMIT_BYTES" , default = 2_097_152 ) ]
47- body_limit_bytes : usize ,
4851}
4952
5053#[ derive( Config ) ]
@@ -175,13 +178,12 @@ struct LinearConfig {
175178 timestamp_tolerance_secs : u64 ,
176179}
177180
178- pub struct ResolvedServerConfig {
181+ pub struct ResolvedHttpServerConfig {
179182 pub port : u16 ,
180- pub body_limit_bytes : usize ,
181183}
182184
183185pub struct ResolvedConfig {
184- pub server : ResolvedServerConfig ,
186+ pub http_server : ResolvedHttpServerConfig ,
185187 pub nats : trogon_nats:: NatsConfig ,
186188 pub github : Option < trogon_source_github:: GithubConfig > ,
187189 pub discord : Option < trogon_source_discord:: DiscordConfig > ,
@@ -227,9 +229,8 @@ fn resolve(cfg: GatewayConfig) -> Result<ResolvedConfig, ConfigError> {
227229 }
228230
229231 Ok ( ResolvedConfig {
230- server : ResolvedServerConfig {
231- port : cfg. server . port ,
232- body_limit_bytes : cfg. server . body_limit_bytes ,
232+ http_server : ResolvedHttpServerConfig {
233+ port : cfg. http_server . port ,
233234 } ,
234235 nats,
235236 github,
@@ -279,7 +280,7 @@ fn resolve_github(
279280) -> Option < trogon_source_github:: GithubConfig > {
280281 let secret_str = section. webhook_secret . filter ( |s| !s. is_empty ( ) ) ?;
281282
282- let webhook_secret = match WebhookSecret :: new ( secret_str) {
283+ let webhook_secret = match GitHubWebhookSecret :: new ( secret_str) {
283284 Ok ( s) => s,
284285 Err ( e) => {
285286 errors. push ( format ! ( "github: invalid webhook_secret: {e}" ) ) ;
@@ -325,7 +326,7 @@ fn resolve_discord(
325326 return None ;
326327 } ;
327328
328- let bot_token = match BotToken :: new ( token_str) {
329+ let bot_token = match DiscordBotToken :: new ( token_str) {
329330 Ok ( s) => s,
330331 Err ( e) => {
331332 errors. push ( format ! ( "discord: invalid bot_token: {e}" ) ) ;
@@ -404,7 +405,7 @@ fn resolve_slack(
404405) -> Option < trogon_source_slack:: SlackConfig > {
405406 let secret_str = section. signing_secret . filter ( |s| !s. is_empty ( ) ) ?;
406407
407- let signing_secret = match SigningSecret :: new ( secret_str) {
408+ let signing_secret = match SlackSigningSecret :: new ( secret_str) {
408409 Ok ( s) => s,
409410 Err ( e) => {
410411 errors. push ( format ! ( "slack: invalid signing_secret: {e}" ) ) ;
@@ -444,7 +445,7 @@ fn resolve_telegram(
444445) -> Option < trogon_source_telegram:: TelegramSourceConfig > {
445446 let secret_str = section. webhook_secret . filter ( |s| !s. is_empty ( ) ) ?;
446447
447- let webhook_secret = match WebhookSecret :: new ( secret_str) {
448+ let webhook_secret = match TelegramWebhookSecret :: new ( secret_str) {
448449 Ok ( s) => s,
449450 Err ( e) => {
450451 errors. push ( format ! ( "telegram: invalid webhook_secret: {e}" ) ) ;
@@ -483,7 +484,7 @@ fn resolve_gitlab(
483484) -> Option < trogon_source_gitlab:: GitlabConfig > {
484485 let webhook_secret_str = section. webhook_secret . filter ( |s| !s. is_empty ( ) ) ?;
485486
486- let webhook_secret = match WebhookSecret :: new ( webhook_secret_str) {
487+ let webhook_secret = match GitLabWebhookSecret :: new ( webhook_secret_str) {
487488 Ok ( s) => s,
488489 Err ( e) => {
489490 errors. push ( format ! ( "gitlab: invalid webhook_secret: {e}" ) ) ;
@@ -522,7 +523,7 @@ fn resolve_linear(
522523) -> Option < trogon_source_linear:: LinearConfig > {
523524 let secret_str = section. webhook_secret . filter ( |s| !s. is_empty ( ) ) ?;
524525
525- let webhook_secret = match WebhookSecret :: new ( secret_str) {
526+ let webhook_secret = match LinearWebhookSecret :: new ( secret_str) {
526527 Ok ( s) => s,
527528 Err ( e) => {
528529 errors. push ( format ! ( "linear: invalid webhook_secret: {e}" ) ) ;
0 commit comments