diff --git a/internal/route/rules/rules.go b/internal/route/rules/rules.go index 4d1dbcc..02378bd 100644 --- a/internal/route/rules/rules.go +++ b/internal/route/rules/rules.go @@ -54,7 +54,13 @@ type ( // if no rule matches and default rule is not set, // the request is passed to the upstream. func (rules Rules) BuildHandler(caller string, up http.Handler) http.HandlerFunc { - var defaultRule *Rule + defaultRule := &Rule{ + Name: "default", + Do: Command{ + raw: "pass", + exec: BypassCommand{}, + }, + } nonDefaultRules := make(Rules, 0, len(rules)) for i, rule := range rules { @@ -79,6 +85,10 @@ func (rules Rules) BuildHandler(caller string, up http.Handler) http.HandlerFunc } } + if len(nonDefaultRules) == 0 { + nonDefaultRules = rules + } + return func(w http.ResponseWriter, r *http.Request) { cache := NewCache() defer cache.Release()