diff --git a/cmd/web/routes.go b/cmd/web/routes.go index 0933b1e..4302753 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -5,14 +5,17 @@ import ( "go-udemy-web-1/pkg/handlers" "net/http" - "github.com/bmizerany/pat" + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" ) func routes(app *config.AppConfig) http.Handler { - mux := pat.New() + mux := chi.NewMux() - mux.Get("/", http.HandlerFunc(handlers.Repo.Home)) - mux.Get("/about", http.HandlerFunc(handlers.Repo.About)) + mux.Use(middleware.Recoverer) + + mux.Get("/", handlers.Repo.Home) + mux.Get("/about", handlers.Repo.About) return mux } diff --git a/go.mod b/go.mod index f522abf..7285979 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module go-udemy-web-1 go 1.21.0 -require github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f // indirect +require ( + github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f // indirect + github.com/go-chi/chi/v5 v5.0.14 // indirect +) diff --git a/go.sum b/go.sum index 5083d07..d1652b0 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f h1:gOO/tNZMjjvTKZWpY7YnXC72ULNLErRtp94LountVE8= github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= +github.com/go-chi/chi/v5 v5.0.14 h1:PyEwo2Vudraa0x/Wl6eDRRW2NXBvekgfxyydcM0WGE0= +github.com/go-chi/chi/v5 v5.0.14/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=