diff options
author | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-11 11:22:47 +0530 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-11 11:22:47 +0530 |
commit | 856f66808b913baff13c815daec3cdde7121e3bd (patch) | |
tree | 60feca35e702d20a0ec8da208b6b59926470bf31 /routes/template.go | |
download | legit-856f66808b913baff13c815daec3cdde7121e3bd.tar.gz legit-856f66808b913baff13c815daec3cdde7121e3bd.tar.bz2 legit-856f66808b913baff13c815daec3cdde7121e3bd.zip |
all: init
Diffstat (limited to 'routes/template.go')
-rw-r--r-- | routes/template.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/routes/template.go b/routes/template.go new file mode 100644 index 0000000..212ed21 --- /dev/null +++ b/routes/template.go @@ -0,0 +1,32 @@ +package routes + +import ( + "html/template" + "net/http" + "os" + "path/filepath" + + "icyphox.sh/legit/config" +) + +func Write404(w http.ResponseWriter, c config.Config) { + w.WriteHeader(404) + tpath := filepath.Join(c.Template.Dir, "404.html") + t := template.Must(template.ParseFiles(tpath)) + t.Execute(w, nil) +} + +func Write500(w http.ResponseWriter, c config.Config) { + w.WriteHeader(500) + tpath := filepath.Join(c.Template.Dir, "500.html") + t := template.Must(template.ParseFiles(tpath)) + t.Execute(w, nil) +} + +func funcMap() template.FuncMap { + return template.FuncMap{ + "prettyMode": func(mode uint32) string { + return os.FileMode(mode).String() + }, + } +} |