fix(route): add workaround for WebUI rule preset loading in validateRules function

- Introduced a temporary fix for loading the "webui.yml" rule preset when the container image is "godoxy-frontend".
- Added error handling for cases where the rule preset is not found.
- Marked the change with a FIXME comment to investigate the underlying issue in the future.
This commit is contained in:
yusing
2025-11-07 16:16:58 +08:00
parent 56374d595a
commit c9db350cbc

View File

@@ -310,6 +310,21 @@ func (r *Route) validate() gperr.Error {
}
func (r *Route) validateRules() error {
// FIXME: hardcoded here as a workaround
// there's already a label "proxy.#1.rule_file=embed://webui.yml"
// but it's not working as expected sometimes.
// TODO: investigate why it's not working and fix it.
if cont := r.ContainerInfo(); cont != nil {
if cont.Image.Name == "godoxy-frontend" {
rules, ok := rulepresets.GetRulePreset("webui.yml")
if !ok {
return errors.New("rule preset `webui.yml` not found")
}
r.Rules = rules
}
return nil
}
if r.RuleFile != "" && len(r.Rules) > 0 {
return errors.New("`rule_file` and `rules` cannot be used together")
} else if r.RuleFile != "" {