learn-go/snippetbox/cmd/web/routes.go

25 lines
552 B
Go
Raw Normal View History

package main
import (
"net/http"
2024-01-26 00:27:56 +00:00
"github.com/justinas/alice"
)
// routes ...
2024-01-25 23:43:07 +00:00
func (app *application) routes() http.Handler {
mux := http.NewServeMux()
// setup server for static files
fileServer := http.FileServer(http.Dir("./ui/static"))
mux.Handle("/static/", http.StripPrefix("/static", fileServer))
mux.HandleFunc("/", app.home)
mux.HandleFunc("/snippet/view", app.snippetView)
mux.HandleFunc("/snippet/create", app.snippetCreate)
2024-01-26 00:27:56 +00:00
standard := alice.New(app.recoverPanic, app.logRequest, secureHeaders)
return standard.Then(mux)
}