rentease/internal/server/routes.go
2024-05-10 12:45:08 +02:00

26 lines
1 KiB
Go

package server
func (s Server) MountHandlers() {
// public
s.Router.GET("/", handleHomePage())
s.Router.POST("/request-booking", handleRequestBooking(s.bs))
// authentication
s.Router.GET("/login", handleLoginPage())
s.Router.POST("/login", handleLogin())
// admin
g := s.Router.Group("")
g.Use(MakeAuthMiddleware(s.secretKey))
g.GET("/bookings", handleListBookingPage(s.bs, s.hc))
g.GET("/bookings/new", handleNewBookingPage(s.hc))
g.POST("/bookings/new", handleCreateBooking(s.bs))
g.GET("/bookings/:id", handleBookingPage(s.bs, s.hc))
g.PUT("/bookings/:id", handleUpdateBooking(s.bs, s.hc))
g.POST("/bookings/:id/items", handleCreateItem(s.bs))
g.POST("/items/:id", handlePayItem(s.bs))
g.PUT("/items/:id", handleUpdateItem(s.bs))
g.GET("/items/:id", handleLineItemForm(s.bs))
g.GET("/bookings/pdf/:id", handleCreateInvoicePdf(s.bs, s.ps, s.hc))
g.GET("/reports", handleReportsPage())
g.GET("/reports/do", handleComputeReport(s.bs, s.hc))
g.GET("/reports/pdf", handleCreateReportPdf(s.bs, s.ps))
}