Add --web-root switch

This commit is contained in:
Philipp Heckel 2022-03-05 21:28:25 -05:00
parent 2743c96694
commit c5ce51f242
5 changed files with 56 additions and 38 deletions

View file

@ -64,6 +64,7 @@ type Config struct {
AttachmentExpiryDuration time.Duration
KeepaliveInterval time.Duration
ManagerInterval time.Duration
WebRootIsApp bool
AtSenderInterval time.Duration
FirebaseKeepaliveInterval time.Duration
SMTPSenderAddr string

View file

@ -83,7 +83,7 @@ var (
webFs embed.FS
webFsCached = &util.CachingEmbedFS{ModTime: time.Now(), FS: webFs}
webSiteDir = "/site"
webHomeIndex = "/home.html" // Landing page, only if "web-index: home"
webHomeIndex = "/home.html" // Landing page, only if "web-root: home"
webAppIndex = "/app.html" // React app
//go:embed docs
@ -300,7 +300,11 @@ func (s *Server) handleInternal(w http.ResponseWriter, r *http.Request, v *visit
}
func (s *Server) handleHome(w http.ResponseWriter, r *http.Request) error {
r.URL.Path = webHomeIndex
if s.config.WebRootIsApp {
r.URL.Path = webAppIndex
} else {
r.URL.Path = webHomeIndex
}
return s.handleStatic(w, r)
}

View file

@ -126,6 +126,11 @@
#
# manager-interval: "1m"
# Defines if the root route (/) is pointing to the landing page (as on ntfy.sh) or the
# web app. If you self-host, you don't want to change this. Can be "app" (default) or "home".
#
# web-root: app
# Rate limiting: Total number of topics before the server rejects new topics.
#
# global-topic-limit: 15000