Added custom headers option
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user