diff --git a/cmd/boardvoting/routes.go b/cmd/boardvoting/routes.go index 3fbabe5..2fffec0 100644 --- a/cmd/boardvoting/routes.go +++ b/cmd/boardvoting/routes.go @@ -21,6 +21,7 @@ import ( "io/fs" "net/http" + "github.com/justinas/alice" "github.com/vearutop/statigz" "github.com/vearutop/statigz/brotli" @@ -45,5 +46,7 @@ func (app *application) routes() http.Handler { mux.HandleFunc("/", app.home) mux.HandleFunc("/motions/", app.motionList) - return app.recoverPanic(app.logRequest(secureHeaders(mux))) + standard := alice.New(app.recoverPanic, app.logRequest, secureHeaders) + + return standard.Then(mux) } diff --git a/go.mod b/go.mod index d3ec881..6c06a61 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,10 @@ require ( gopkg.in/yaml.v2 v2.4.0 ) -require github.com/stretchr/testify v1.7.0 +require ( + github.com/justinas/alice v1.2.0 + github.com/stretchr/testify v1.7.0 +) require ( github.com/Masterminds/goutils v1.1.1 // indirect diff --git a/go.sum b/go.sum index 6e21654..d528e53 100644 --- a/go.sum +++ b/go.sum @@ -752,6 +752,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= +github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo= +github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/k0kubun/pp v2.3.0+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=