Added custom headers option

This commit is contained in:
2026-03-31 14:17:46 +02:00
parent e4b9c36486
commit f0eeaecbb1
3 changed files with 69 additions and 12 deletions
+15
View File
@@ -2,6 +2,7 @@ package handlers
import (
"os"
"path"
"path/filepath"
"quay/internal/config"
@@ -21,6 +22,20 @@ func NewStaticHandler(storagePath string, siteMap map[string]config.SiteConfig)
urlPath := filepath.Clean(c.Path())
for _, header := range site.CustomHeaders {
var matched bool
if header.Regex && header.Compiled != nil {
matched = header.Compiled.MatchString(urlPath)
} else {
matched, _ = path.Match(header.Source, urlPath)
}
if matched {
for key, value := range header.Headers {
c.Set(key, value)
}
}
}
for _, rule := range site.ForwardRules {
if rule.Regex && rule.Compiled != nil {
match := rule.Compiled.FindStringSubmatchIndex(urlPath)