Add static file serving

This commit is contained in:
Eliot Whalan 2016-06-23 11:25:12 +10:00
parent c463ff8282
commit 22e9ca4503
No known key found for this signature in database
GPG Key ID: C0A42175139840D6
1 changed files with 2 additions and 2 deletions

View File

@ -213,13 +213,13 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
}
func main() {
router := mux.NewRouter().StrictSlash(true)
router.PathPrefix("/").Handler(http.StripPrefix("/", http.FileServer(http.Dir("static/"))))
router := mux.NewRouter()
router.HandleFunc("/p/{pasteId}", pasteHandler)
router.HandleFunc("/p/{pasteId}/{lang}", langHandler)
router.HandleFunc("/save", saveHandler)
router.HandleFunc("/save/{output}", saveHandler)
router.HandleFunc("/del/{pasteId}/{delKey}", delHandler)
router.PathPrefix("/").Handler(http.StripPrefix("/", http.FileServer(http.Dir("static/"))))
err := http.ListenAndServe(PORT, router)
if err != nil {
log.Fatal(err)