summaryrefslogtreecommitdiff
path: root/binnit.go
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2017-07-03 13:41:00 +0100
committerKatolaZ <katolaz@freaknet.org>2017-07-03 13:41:00 +0100
commit13c5a2ab438f2496370ef10e7df8096e30962b66 (patch)
tree0fdcd94c670000663f776c583f36f4be046377bf /binnit.go
parent8f5b41695d0f2b291b4ce3e26ee24c5f26e04cfb (diff)
paste.Retrieve(). Small changes to the template
Diffstat (limited to 'binnit.go')
-rw-r--r--binnit.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/binnit.go b/binnit.go
index 0c4c49d..1b11f03 100644
--- a/binnit.go
+++ b/binnit.go
@@ -61,7 +61,6 @@ func min (a, b int) int {
func handle_get_paste(w http.ResponseWriter, r *http.Request) {
var paste_name, orig_name string
- var err error
orig_name = filepath.Clean(r.URL.Path)
paste_name = p_conf.paste_dir + "/" + orig_name
@@ -75,9 +74,11 @@ func handle_get_paste(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, p_conf.templ_dir + "/index.html")
} 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)
- s, err := prepare_paste_page(&p_conf, orig_name)
+
+ title, date, content, err := paste.Retrieve(paste_name)
+
+ if err == nil {
+ s, err := prepare_paste_page(title, date, content, p_conf.templ_dir)
if err == nil {
fmt.Fprintf(w, "%s", s)
return
@@ -87,7 +88,7 @@ func handle_get_paste(w http.ResponseWriter, r *http.Request) {
}
} else {
// otherwise, we give say we didn't find it
- fmt.Fprintf(w, "Paste '%s' not found\n", orig_name)
+ fmt.Fprintf(w, "%s\n", err)
return
}
}