Added config setting to disable site
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"quay/internal/config"
|
||||
@@ -16,6 +15,10 @@ func NewStaticHandler(storagePath string, siteMap map[string]config.SiteConfig)
|
||||
return c.Status(fiber.StatusNotFound).SendString("Site not found")
|
||||
}
|
||||
|
||||
if !site.Enabled {
|
||||
return c.Status(fiber.StatusServiceUnavailable).SendString("Site is currently unavailable")
|
||||
}
|
||||
|
||||
urlPath := filepath.Clean(c.Path())
|
||||
|
||||
for _, rule := range site.ForwardRules {
|
||||
@@ -23,7 +26,6 @@ func NewStaticHandler(storagePath string, siteMap map[string]config.SiteConfig)
|
||||
match := rule.Compiled.FindStringSubmatchIndex(urlPath)
|
||||
if match != nil {
|
||||
dest := rule.Compiled.ExpandString([]byte{}, rule.Destination, urlPath, match)
|
||||
log.Printf("Forwarding %s to %s based on regex rule", urlPath, dest)
|
||||
return c.Redirect().Status(rule.StatusCode).To(string(dest))
|
||||
}
|
||||
} else if rule.Source == urlPath {
|
||||
|
||||
Reference in New Issue
Block a user