From 09979dcab01643349cee425b71fa3b4db24f8d60 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Sun, 20 Sep 2020 20:56:53 -0400 Subject: Save the index in memory and only rebuild if cleared --- page/http.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'page/http.go') diff --git a/page/http.go b/page/http.go index 7e1d780..b3622be 100644 --- a/page/http.go +++ b/page/http.go @@ -8,6 +8,7 @@ import ( ) func SetupHandlers() { + http.HandleFunc("/rebuildIndex/", RebuildIndexHandler) http.Handle("/static/", StaticHandler()) http.HandleFunc("/", PageHandler) } @@ -43,6 +44,15 @@ func PageHandler(w http.ResponseWriter, r *http.Request) { } +func RebuildIndexHandler(w http.ResponseWriter, r *http.Request) { + if r.Method != "POST" { + pageIndex = nil + p := &Page{Path: "index"} + _, _ = p.Index() + } + return +} + func StaticHandler() (h http.Handler) { return http.StripPrefix("/static/", http.FileServer(http.Dir("static"))) } -- cgit v1.2.3