Files
ntfy-bridge/webhook.v
T
bruno 4e1d7cd94a Add config validation and dashboard
Add YAML config loading with validation, env overrides for secrets, and
a web dashboard exposing health, stats, and recent events.
2026-08-03 12:12:12 -04:00

48 lines
994 B
V

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
}
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
}
}
return routes
}