ch9.3
This commit is contained in:
@@ -17,12 +17,13 @@ func (app *application) routes() http.Handler {
|
||||
fileServer := http.FileServer(http.Dir("./ui/static/"))
|
||||
router.Handler(http.MethodGet, "/static/", http.StripPrefix("/static", fileServer))
|
||||
|
||||
router.HandlerFunc(http.MethodGet, "/", app.home)
|
||||
router.HandlerFunc(http.MethodGet, "/snippet/view/:id", app.snippetView)
|
||||
router.HandlerFunc(http.MethodGet, "/snippet/create", app.snippetCreate)
|
||||
router.HandlerFunc(http.MethodPost, "/snippet/create", app.snippetCreatePost)
|
||||
dynamic := alice.New(app.sessionManager.LoadAndSave)
|
||||
|
||||
router.Handler(http.MethodGet, "/", dynamic.ThenFunc(app.home))
|
||||
router.Handler(http.MethodGet, "/snippet/view/:id", dynamic.ThenFunc(app.snippetView))
|
||||
router.Handler(http.MethodGet, "/snippet/create", dynamic.ThenFunc(app.snippetCreate))
|
||||
router.Handler(http.MethodPost, "/snippet/create", dynamic.ThenFunc(app.snippetCreatePost))
|
||||
|
||||
standard := alice.New(app.recoverPanic, app.logRequest, secureHeaders)
|
||||
|
||||
return standard.Then(router)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user