Use servecontent to serve user gemini content
alex wennerberg alex@alexwennerberg.com
Wed, 10 Feb 2021 21:13:08 -0800
1 files changed,
5 insertions(+),
2 deletions(-)
jump to
M
http.go
→
http.go
@@ -629,11 +629,14 @@ URI *url.URL
GeminiURI *url.URL Config Config }{template.HTML(htmlDoc.Content), favicon, htmlDoc.Title, &uri, &uri, c} - err = t.ExecuteTemplate(w, "user_page.html", data) + buff := bytes.NewBuffer([]byte{}) + err = t.ExecuteTemplate(buff, "user_page.html", data) if err != nil { serverError(w, err) return } + breader := bytes.NewReader(buff.Bytes()) + http.ServeContent(w, r, "", stat.ModTime(), breader) } else { http.ServeFile(w, r, fullPath) }@@ -783,7 +786,7 @@ hostname := s[0]
serveMux.HandleFunc(hostname+"/", rootHandler) serveMux.HandleFunc(hostname+"/my_site", mySiteHandler) - serveMux.HandleFunc(hostname+"/me", limit(myAccountHandler)) + serveMux.HandleFunc(hostname+"/me", myAccountHandler) serveMux.HandleFunc(hostname+"/my_site/flounder-archive.zip", archiveHandler) serveMux.HandleFunc(hostname+"/admin", adminHandler) serveMux.HandleFunc(hostname+"/edit/", editFileHandler)