setting default cache time super low to test cache expirations

This commit is contained in:
dtookey 2022-07-21 09:19:36 -04:00
parent 41800f1a13
commit a72b54a114
3 changed files with 30 additions and 24 deletions

29
servlet/templates.go Normal file
View File

@ -0,0 +1,29 @@
package servlet
import (
"html/template"
"io/ioutil"
"net/http"
"os"
)
func RenderTemplate(w http.ResponseWriter, pathlike string, data any) {
templateHelper := template.New(pathlike)
f, err := os.OpenFile(pathlike, os.O_RDONLY, 0777)
if err != nil {
panic(err)
}
defer f.Close()
content, err := ioutil.ReadAll(f)
if err != nil {
panic(err)
}
templ, err := templateHelper.Parse(string(content))
err = templ.Execute(w, data)
if err != nil {
panic(err)
}
}

View File

@ -3,33 +3,10 @@ package vinegarUtil
import (
"bytes"
gzip2 "compress/gzip"
"html/template"
"io/ioutil"
"net/http"
"os"
)
func RenderTemplate(w http.ResponseWriter, pathlike string, data any) {
templateHelper := template.New(pathlike)
f, err := os.OpenFile(pathlike, os.O_RDONLY, 0777)
if err != nil {
panic(err)
}
defer f.Close()
content, err := ioutil.ReadAll(f)
if err != nil {
panic(err)
}
templ, err := templateHelper.Parse(string(content))
err = templ.Execute(w, data)
if err != nil {
panic(err)
}
}
func GetDiskContent(filePath string) (*[]byte, bool) {
_, ferr := os.Stat(filePath)
if os.IsNotExist(ferr) {

View File

@ -8,7 +8,7 @@ import (
)
const (
DefaultCacheTimeInMinutes = 15
DefaultCacheTimeInMinutes = 1
)
type (