Skip to content

Commit 5e545f1

Browse files
committed
Serve wildcard static files with StripPrefix and FileServer
1 parent 391132d commit 5e545f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,9 @@ func main() {
441441
router.HandleFunc("/error/{errorcode}", func(w http.ResponseWriter, r *http.Request) {
442442
ErrorPage(db, w, r)
443443
}).Methods("GET")
444-
router.PathPrefix("/css/").Handler(http.FileServer(http.Dir(STATIC_FILES_DIR + "/css/")))
445-
router.PathPrefix("/js/").Handler(http.FileServer(http.Dir(STATIC_FILES_DIR + "/js/")))
446-
router.PathPrefix("/img/").Handler(http.FileServer(http.Dir(STATIC_FILES_DIR + "/img/")))
447-
router.PathPrefix("/fonts/").Handler(http.FileServer(http.Dir(STATIC_FILES_DIR + "/fonts/")))
444+
router.PathPrefix("/css/{css}").Handler(http.StripPrefix("/css/", http.FileServer(http.Dir(STATIC_FILES_DIR+"/css/"))))
445+
router.PathPrefix("/js/{js}").Handler(http.StripPrefix("/js/", http.FileServer(http.Dir(STATIC_FILES_DIR+"/js/"))))
446+
router.PathPrefix("/img/{img}").Handler(http.StripPrefix("/img/", http.FileServer(http.Dir(STATIC_FILES_DIR+"/img/"))))
447+
router.PathPrefix("/fonts/{fonts}").Handler(http.StripPrefix("/fonts/", http.FileServer(http.Dir(STATIC_FILES_DIR+"/fonts/"))))
448448
log.Fatal(http.ListenAndServe(":1337", router))
449449
}

0 commit comments

Comments
 (0)