2024-06-28 10:59:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go-udemy-web-1/pkg/config"
|
|
|
|
"go-udemy-web-1/pkg/handlers"
|
|
|
|
"net/http"
|
|
|
|
|
2024-06-28 11:14:05 +00:00
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/go-chi/chi/v5/middleware"
|
2024-06-28 10:59:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func routes(app *config.AppConfig) http.Handler {
|
2024-06-28 11:14:05 +00:00
|
|
|
mux := chi.NewMux()
|
2024-06-28 10:59:47 +00:00
|
|
|
|
2024-06-28 11:14:05 +00:00
|
|
|
mux.Use(middleware.Recoverer)
|
2024-06-28 11:33:43 +00:00
|
|
|
mux.Use(WriteToConsole)
|
|
|
|
mux.Use(NoSurf)
|
2024-06-28 13:30:00 +00:00
|
|
|
mux.Use(SessionLoad)
|
2024-06-28 11:14:05 +00:00
|
|
|
|
|
|
|
mux.Get("/", handlers.Repo.Home)
|
|
|
|
mux.Get("/about", handlers.Repo.About)
|
2024-06-28 10:59:47 +00:00
|
|
|
|
2024-06-28 20:30:19 +00:00
|
|
|
fileServer := http.FileServer(http.Dir("./static/"))
|
|
|
|
mux.Handle("/static/*", http.StripPrefix("/static", fileServer))
|
|
|
|
|
2024-06-28 10:59:47 +00:00
|
|
|
return mux
|
|
|
|
}
|