36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
|
|
package routes
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/gorilla/mux"
|
||
|
|
"go_project/internal/handlers"
|
||
|
|
"go_project/pkg/behaivor"
|
||
|
|
"go_project/pkg/information"
|
||
|
|
"net/http"
|
||
|
|
)
|
||
|
|
|
||
|
|
func DefaultRouter() *mux.Router {
|
||
|
|
router := mux.NewRouter()
|
||
|
|
declareRoutes(router)
|
||
|
|
http.Handle("/", router)
|
||
|
|
|
||
|
|
err := router.Walk(information.AboutRoute)
|
||
|
|
behaivor.Anxiety("Error walking routes", err)
|
||
|
|
|
||
|
|
return router
|
||
|
|
}
|
||
|
|
|
||
|
|
var declareRoutes = func(router *mux.Router) {
|
||
|
|
// End points for Table record
|
||
|
|
router.HandleFunc("/tables", handlers.GetAllTables).Methods("GET")
|
||
|
|
router.HandleFunc("/table/{id:[0-9]+}", handlers.GetTableById).Methods("GET")
|
||
|
|
router.HandleFunc("/table", handlers.CreateTable).Methods("POST")
|
||
|
|
router.HandleFunc("/table", handlers.UpdateTable).Methods("PUT")
|
||
|
|
router.HandleFunc("/table/{id:[0-9]+}", handlers.DeleteTableById).Methods("DELETE")
|
||
|
|
// End points for Booking record
|
||
|
|
router.HandleFunc("/bookings", handlers.GetAllBookings).Methods("GET")
|
||
|
|
router.HandleFunc("/booking/{id:[0-9]+}", handlers.GetBookingById).Methods("GET")
|
||
|
|
router.HandleFunc("/booking", handlers.CreateBooking).Methods("POST")
|
||
|
|
router.HandleFunc("/booking", handlers.UpdateBooking).Methods("PUT")
|
||
|
|
router.HandleFunc("/booking/{id:[0-9]+}", handlers.DeleteBookingById).Methods("DELETE")
|
||
|
|
}
|