2024-06-28 12:59:47 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-06-30 16:41:46 +02:00
|
|
|
"go-udemy-web-1/internal/config"
|
|
|
|
"go-udemy-web-1/internal/handlers"
|
2024-06-28 12:59:47 +02:00
|
|
|
"net/http"
|
|
|
|
|
2024-06-28 13:14:05 +02:00
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/go-chi/chi/v5/middleware"
|
2024-06-28 12:59:47 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func routes(app *config.AppConfig) http.Handler {
|
2024-06-28 13:14:05 +02:00
|
|
|
mux := chi.NewMux()
|
2024-06-28 12:59:47 +02:00
|
|
|
|
2024-06-28 13:14:05 +02:00
|
|
|
mux.Use(middleware.Recoverer)
|
2024-06-28 13:33:43 +02:00
|
|
|
mux.Use(WriteToConsole)
|
2024-07-13 18:19:51 +02:00
|
|
|
mux.Use(NoSurf) // XXX: Maybe this middleware makes that I don't have to r.ParseForm before Get the elements.
|
2024-06-28 15:30:00 +02:00
|
|
|
mux.Use(SessionLoad)
|
2024-06-28 13:14:05 +02:00
|
|
|
|
|
|
|
mux.Get("/", handlers.Repo.Home)
|
|
|
|
mux.Get("/about", handlers.Repo.About)
|
2024-06-29 21:30:06 +02:00
|
|
|
mux.Get("/contact", handlers.Repo.Contact)
|
|
|
|
mux.Get("/generals-quarters", handlers.Repo.Generals)
|
|
|
|
mux.Get("/majors-suite", handlers.Repo.Majors)
|
2024-06-30 10:51:29 +02:00
|
|
|
mux.Get("/availability", handlers.Repo.Availability)
|
|
|
|
mux.Post("/availability", handlers.Repo.PostAvailability)
|
2024-06-30 16:37:57 +02:00
|
|
|
mux.Post("/availability-json", handlers.Repo.AvailabilityJSON)
|
2024-06-29 21:30:06 +02:00
|
|
|
mux.Get("/make-reservation", handlers.Repo.MakeReservation)
|
2024-06-30 17:08:47 +02:00
|
|
|
mux.Post("/make-reservation", handlers.Repo.PostMakeReservation)
|
2024-07-01 14:19:38 +02:00
|
|
|
mux.Get("/reservation-summary", handlers.Repo.ReservationSummary)
|
2024-07-10 22:08:23 +02:00
|
|
|
mux.Get("/choose-room/{id}", handlers.Repo.ChooseRoom)
|
2024-07-11 23:01:10 +02:00
|
|
|
mux.Get("/book-room", handlers.Repo.BookRoom)
|
2024-06-28 12:59:47 +02:00
|
|
|
|
2024-06-28 22:30:19 +02:00
|
|
|
fileServer := http.FileServer(http.Dir("./static/"))
|
|
|
|
mux.Handle("/static/*", http.StripPrefix("/static", fileServer))
|
|
|
|
|
2024-06-28 12:59:47 +02:00
|
|
|
return mux
|
|
|
|
}
|