Using chi for routing
This commit is contained in:
parent
daef31f070
commit
e1b990dfd3
@ -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
|
||||
}
|
||||
|
5
go.mod
5
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
|
||||
)
|
||||
|
2
go.sum
2
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=
|
||||
|
Loading…
Reference in New Issue
Block a user