diff options
author | KatolaZ <katolaz@freaknet.org> | 2017-07-01 00:45:51 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2017-07-01 00:45:51 +0100 |
commit | e29d79e5f9785d039175da43704d02907b54ab47 (patch) | |
tree | 05d915882199105fc0bf57889fcbb7cfef1c4229 /main.go | |
parent | 32e86d1129f200c776f879da835a6659427ca707 (diff) |
basic templating added (only for paste visualisation)
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -52,7 +52,15 @@ func handle_get_paste(w http.ResponseWriter, r *http.Request) { } else { // otherwise, if the requested paste exists, we serve it... if _, err = os.Stat(paste_name); err == nil && orig_name != "./" { - http.ServeFile(w, r, paste_name) + //http.ServeFile(w, r, paste_name) + s, err := prepare_paste_page(&p_conf, orig_name) + if err == nil { + fmt.Fprintf(w, "%s", s) + return + } else { + fmt.Fprintf(w, "Error recovering paste '%s'\n", orig_name) + return + } } else { // otherwise, we give say we didn't find it fmt.Fprintf(w, "Paste '%s' not found\n", orig_name) @@ -142,6 +150,8 @@ func main() { fmt.Fprintf(os.Stderr, "Error opening logfile: %s. Exiting\n", p_conf.log_fname) os.Exit(1) } + defer f.Close() + log.SetOutput(io.Writer(f)) log.SetPrefix("[binit]: ") |