diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2025-07-17 22:36:19 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2025-07-17 22:36:19 +0100 |
| commit | e1f6b6b8f3465b4819364efc497fea6d9ddad67e (patch) | |
| tree | 47bfd55b69d7d2668e7193fbef2c4e7badd1fb1d /pkg | |
| parent | 4b58544300847e5faf19be5baa4eb177a86b2b0f (diff) | |
Implement disabled flag
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/html/status.go (renamed from pkg/html/notfound.go) | 8 | ||||
| -rw-r--r-- | pkg/site/fs.go | 5 |
2 files changed, 13 insertions, 0 deletions
diff --git a/pkg/html/notfound.go b/pkg/html/status.go index ceb521f..569a236 100644 --- a/pkg/html/notfound.go +++ b/pkg/html/status.go @@ -23,3 +23,11 @@ func NotFoundSitePage(host string) Node { P(Text(fmt.Sprintf("The site %s is unknown", host))), ) } + +func ForbiddenDisabledPage(host string) Node { + return Page("Forbidden", + H1(Text("Forbidden")), + + P(Text(fmt.Sprintf("Site %s is disabled", host))), + ) +} diff --git a/pkg/site/fs.go b/pkg/site/fs.go index c9bbe21..b4a941d 100644 --- a/pkg/site/fs.go +++ b/pkg/site/fs.go @@ -21,6 +21,11 @@ func NewSiteFileServer(root http.FileSystem, siteConfig *config.SiteConfig) *Sit } func (fs *SiteFileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if fs.siteConfig.Flags&config.FlagDisable != 0 { + html.ForbiddenDisabledPage(fs.siteConfig.Host).Render(w) + return + } + path := filepath.Clean(r.URL.Path) file, err := fs.root.Open(path) |
