From 92d493205cfe58ff13b40667f613cabb3e145578 Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Thu, 23 Jun 2016 18:40:20 +1000 Subject: [PATCH] Add raw paste view --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index a17e26a..bd0244c 100644 --- a/main.go +++ b/main.go @@ -210,9 +210,13 @@ func getPaste(paste string) string { } func pasteHandler(w http.ResponseWriter, r *http.Request) { +} + +func rawHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) paste := vars["pasteId"] s := getPaste(paste) + w.Header().Set("Content-Type", "plain/text") io.WriteString(w, s) } @@ -220,6 +224,7 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) { func main() { router := mux.NewRouter() router.HandleFunc("/p/{pasteId}", pasteHandler) + router.HandleFunc("/raw/{pasteId}", rawHandler) router.HandleFunc("/p/{pasteId}/{lang}", langHandler) router.HandleFunc("/save", saveHandler) router.HandleFunc("/save/{output}", saveHandler)