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.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user