diff --git a/app/handlers/static.go b/app/handlers/static.go index 3b55878..ca80534 100644 --- a/app/handlers/static.go +++ b/app/handlers/static.go @@ -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 { diff --git a/config.example.yaml b/config.example.yaml index 0a93fa8..c6a1b93 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -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 @@ -17,7 +18,7 @@ sites: destination: https://v$1.docs.my-lib.com/ status_code: 301 regex: true - + - source: ^/blog/(?P[^/]+)$ destination: /posts/${slug} status_code: 302 @@ -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}" \ No newline at end of file + deploy_token: "${OTHER_DOCS_DEPLOY_TOKEN}" + enabled: true \ No newline at end of file diff --git a/internal/config/config.go b/internal/config/config.go index 10a0d20..d264f99 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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"`