diff options
author | xengineering <me@xengineering.eu> | 2023-02-08 20:53:20 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-02-08 21:01:27 +0100 |
commit | f9a5140071703faf0c7515a05f52e69fdc1f11ba (patch) | |
tree | ee073f3c7fc1a6bbda1eee6e3bec076e73363740 /utils/templates.go | |
parent | 9005de11ef8b7cf32cc8503e8b5f134eca47b4fb (diff) | |
download | ceres-f9a5140071703faf0c7515a05f52e69fdc1f11ba.tar ceres-f9a5140071703faf0c7515a05f52e69fdc1f11ba.tar.zst ceres-f9a5140071703faf0c7515a05f52e69fdc1f11ba.zip |
Move all sources to package main
This project is not so big that it needs multiple packages.
Diffstat (limited to 'utils/templates.go')
-rw-r--r-- | utils/templates.go | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/utils/templates.go b/utils/templates.go deleted file mode 100644 index 00a8eb2..0000000 --- a/utils/templates.go +++ /dev/null @@ -1,32 +0,0 @@ - -package utils - -import ( - "log" - "net/http" - "io/ioutil" - "text/template" // FIXME switch to html/template for security reasons - // and make a workaround for rendered Markdown insertion -) - -func ServeTemplate(w http.ResponseWriter, name string, path string, data interface{}) { - - templateFile,err := ioutil.ReadFile(path) - if err != nil { - log.Print(err) - http.Error(w, http.StatusText(404), 404) - return - } - tmpl,err := template.New(name).Parse(string(templateFile)) - if err != nil { - log.Print(err) - http.Error(w, http.StatusText(404), 404) - return - } - err = tmpl.Execute(w, data) - if err != nil { - log.Print(err) - http.Error(w, http.StatusText(404), 404) - return - } -} |