aboutsummaryrefslogtreecommitdiff
path: root/page/http.go
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2020-09-20 20:56:53 -0400
committerMitch Riedstra <mitch@riedstra.us>2020-09-20 20:56:53 -0400
commit09979dcab01643349cee425b71fa3b4db24f8d60 (patch)
tree333d7c4c8941b6ad8d4092d700566956d107521a /page/http.go
parent3b94493a21f227962a01ec0b11fd855178985604 (diff)
downloadgo-website-09979dcab01643349cee425b71fa3b4db24f8d60.tar.gz
go-website-09979dcab01643349cee425b71fa3b4db24f8d60.tar.xz
Save the index in memory and only rebuild if clearedv0.0.7
Diffstat (limited to 'page/http.go')
-rw-r--r--page/http.go10
1 files changed, 10 insertions, 0 deletions
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")))
}