lets-go:6.5 alice

This commit is contained in:
tamsin johnson 2024-01-25 16:27:56 -08:00
parent 2b57596bbc
commit d6d629884b
3 changed files with 11 additions and 2 deletions

View File

@ -2,6 +2,8 @@ package main
import (
"net/http"
"github.com/justinas/alice"
)
// routes ...
@ -16,5 +18,7 @@ func (app *application) routes() http.Handler {
mux.HandleFunc("/snippet/view", app.snippetView)
mux.HandleFunc("/snippet/create", app.snippetCreate)
return app.recoverPanic(app.logRequest(secureHeaders(mux)))
standard := alice.New(app.recoverPanic, app.logRequest, secureHeaders)
return standard.Then(mux)
}

View File

@ -2,4 +2,7 @@ module snippetbox.chaosfem.tw
go 1.21.4
require github.com/go-sql-driver/mysql v1.7.1 // indirect
require (
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/justinas/alice v1.2.0 // indirect
)

View File

@ -1,2 +1,4 @@
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo=
github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA=