diff --git a/src/handlers.go b/src/handlers.go index ee9d1dc..b58197c 100644 --- a/src/handlers.go +++ b/src/handlers.go @@ -313,6 +313,10 @@ func (ctx *Instance) dehydrateHandler(w http.ResponseWriter, req *http.Request) } func (ctx *Instance) manifestHandler(w http.ResponseWriter, req *http.Request) { + if (! ctx.Runtime.export_manifest) { + http.Error(w, "Endpoint disabled", http.StatusForbidden) + return + } manifest := make([]string, 0) manifest = append(manifest, "puzzles.json") manifest = append(manifest, "points.json") diff --git a/src/instance.go b/src/instance.go index 1d3a26f..fb274e3 100644 --- a/src/instance.go +++ b/src/instance.go @@ -15,6 +15,10 @@ import ( "time" ) +type RuntimeConfig struct { + export_manifest bool +} + type Instance struct { Base string MothballDir string @@ -22,6 +26,8 @@ type Instance struct { ThemeDir string AttemptInterval time.Duration + Runtime RuntimeConfig + categories map[string]*Mothball update chan bool jPuzzleList []byte diff --git a/src/maintenance.go b/src/maintenance.go index abd51e0..a4cec4f 100644 --- a/src/maintenance.go +++ b/src/maintenance.go @@ -124,6 +124,9 @@ func (ctx *Instance) tidy() { // Do they want to reset everything? ctx.MaybeInitialize() + // Check set config + ctx.UpdateConfig() + // Refresh all current categories for categoryName, mb := range ctx.categories { if err := mb.Refresh(); err != nil { @@ -286,6 +289,18 @@ func (ctx *Instance) isEnabled() bool { return true } +func (ctx *Instance) UpdateConfig() { + // Handle export manifest + if _, err := os.Stat(ctx.StatePath("export_manifest")); err == nil { + log.Print("Enabling manifest export") + ctx.Runtime.export_manifest = true + } else { + log.Print("Disabling manifest export") + ctx.Runtime.export_manifest = false + } + +} + // maintenance is the goroutine that runs a periodic maintenance task func (ctx *Instance) Maintenance(maintenanceInterval time.Duration) { for {