# HG changeset patch # User Christophe de Vienne <christophe@cdevienne.info> # Date 1732724012 -3600 # Wed Nov 27 17:13:32 2024 +0100 # Node ID 5b9bb41889330bc2ef502a3d89baf82096702675 # Parent 67524076bb1d34a03dfc47f45385ccfe2c22f878 cmd: WithUI: add 'ExcludePrefix' option diff --git a/cmd/program_ui.go b/cmd/program_ui.go --- a/cmd/program_ui.go +++ b/cmd/program_ui.go @@ -75,9 +75,10 @@ } type UIConfig struct { - Name string - Description string - Prefix string + Name string + Description string + Prefix string + ExcludePrefix []string } func WithUI(uifs fs.FS, cfg *UIConfig) Option { @@ -118,6 +119,13 @@ next.ServeHTTP(rw, r) } } + for _, p := range cfg.ExcludePrefix { + if strings.HasPrefix(r.URL.Path, p) { + next.ServeHTTP(rw, r) + + return + } + } accepted, err := accept.Negotiate( r.Header.Get("Accept"), "text/html", "application/json")