Added config setting to disable site

This commit is contained in:
2026-03-31 13:56:13 +02:00
parent dcc8201099
commit e4b9c36486
3 changed files with 10 additions and 4 deletions
+4 -2
View File
@@ -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 {
+3
View File
@@ -8,6 +8,7 @@ sites:
branch: gh-pages
domain: docs.my-lib.com
deploy_token: "${MY_LIB_DEPLOY_TOKEN}"
enabled: true
forward_rules:
- source: /npm
destination: https://www.npmjs.com/package/my-lib
@@ -29,9 +30,11 @@ sites:
domain: yourname.com
spa: true
deploy_token: "${PORTFOLIO_DEPLOY_TOKEN}"
enabled: true
- repo: other-docs
owner: yourname
branch: gh-pages
domain: other-docs.yourdomain.com
deploy_token: "${OTHER_DOCS_DEPLOY_TOKEN}"
enabled: true
+1
View File
@@ -23,6 +23,7 @@ type SiteConfig struct {
Owner string `yaml:"owner"`
Branch string `yaml:"branch"`
Domain string `yaml:"domain"`
Enabled bool `yaml:"enabled"`
SPA bool `yaml:"spa"`
NotFoundFile string `yaml:"not_found_file"`
DeployToken string `yaml:"deploy_token"`