Add raw paste view
This commit is contained in:
parent
8ac62831e2
commit
92d493205c
5
main.go
5
main.go
|
@ -210,9 +210,13 @@ func getPaste(paste string) string {
|
||||||
|
|
||||||
}
|
}
|
||||||
func pasteHandler(w http.ResponseWriter, r *http.Request) {
|
func pasteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func rawHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
paste := vars["pasteId"]
|
paste := vars["pasteId"]
|
||||||
s := getPaste(paste)
|
s := getPaste(paste)
|
||||||
|
w.Header().Set("Content-Type", "plain/text")
|
||||||
io.WriteString(w, s)
|
io.WriteString(w, s)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -220,6 +224,7 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
func main() {
|
func main() {
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/p/{pasteId}", pasteHandler)
|
router.HandleFunc("/p/{pasteId}", pasteHandler)
|
||||||
|
router.HandleFunc("/raw/{pasteId}", rawHandler)
|
||||||
router.HandleFunc("/p/{pasteId}/{lang}", langHandler)
|
router.HandleFunc("/p/{pasteId}/{lang}", langHandler)
|
||||||
router.HandleFunc("/save", saveHandler)
|
router.HandleFunc("/save", saveHandler)
|
||||||
router.HandleFunc("/save/{output}", saveHandler)
|
router.HandleFunc("/save/{output}", saveHandler)
|
||||||
|
|
Loading…
Reference in New Issue