module main // WebhookRoute maps a webhook path to its source type and index for O(1) dispatch. pub enum SourceKind { gitea uptime_kuma cron generic plugin } pub struct WebhookRoute { kind SourceKind index int // index in the config's source array } // build_webhook_routes constructs a map of webhook_path → WebhookRoute // for O(1) dispatch instead of scanning all sources on every request. pub fn build_webhook_routes(cfg Config) map[string]WebhookRoute { mut routes := map[string]WebhookRoute{} for i, src in cfg.sources.gitea { routes[src.webhook_path] = WebhookRoute{ kind: .gitea index: i } } for i, src in cfg.sources.uptime_kuma { routes[src.webhook_path] = WebhookRoute{ kind: .uptime_kuma index: i } } for i, src in cfg.sources.cron { routes[src.webhook_path] = WebhookRoute{ kind: .cron index: i } } for i, src in cfg.sources.generic { routes[src.webhook_path] = WebhookRoute{ kind: .generic index: i } } for i, _ in cfg.sources.plugin { // Plugin sources don't have webhook_path — they run as background tasks // Reserved for future webhook-triggered plugin support _ = i } return routes }