Server static files
This commit is contained in:
parent
2ba0a0024e
commit
73a1c8bc02
7 changed files with 52 additions and 14 deletions
|
|
@ -15,5 +15,21 @@ func main() {
|
|||
notesRouter := views.GetRoutes("/notes")
|
||||
|
||||
router.Handle("/notes/", http.StripPrefix("/notes", notesRouter))
|
||||
router.Handle(
|
||||
conf.Conf.Static.Root,
|
||||
logger(
|
||||
http.StripPrefix(
|
||||
"/static",
|
||||
http.FileServer(http.Dir(conf.Conf.Static.Dir)),
|
||||
),
|
||||
),
|
||||
)
|
||||
log.Fatal(http.ListenAndServe(":8080", router))
|
||||
}
|
||||
|
||||
func logger(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Print(r.URL.Path)
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue