Using chi for routing

This commit is contained in:
Muyao CHEN
2024-06-28 13:14:05 +02:00
parent daef31f070
commit e1b990dfd3
3 changed files with 13 additions and 5 deletions

View File

@ -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
}