mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
46 lines
1.6 KiB
Go
46 lines
1.6 KiB
Go
package server
|
|
|
|
import (
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/labstack/echo/v4/middleware"
|
|
)
|
|
|
|
func (s Server) MountHandlers() {
|
|
s.Router.GET("/healthz", handleHealthCheck())
|
|
s.Router.GET("/", handleLoginPage())
|
|
s.Router.POST("/", handleLogin(s.as))
|
|
|
|
api := s.Router.Group("/api")
|
|
api.Use(middleware.KeyAuthWithConfig(middleware.KeyAuthConfig{
|
|
KeyLookup: "header:api-key",
|
|
Validator: func(key string, c echo.Context) (bool, error) {
|
|
return s.as.ValidateApiKey(key), nil
|
|
},
|
|
}))
|
|
api.POST("/sync", handleSync(s.bs))
|
|
api.GET("/bookings", handleBookingList(s.bs))
|
|
|
|
private := s.Router.Group("")
|
|
private.Use(MakeAuthMiddleware(s.as))
|
|
|
|
private.GET("/bookings", handleBookingListPage(s.bs, s.hc))
|
|
private.GET("/bookings/new", handleBookingCreatePage(s.hc))
|
|
private.POST("/bookings/new", handleBookingCreate(s.bs))
|
|
private.GET("/bookings/:id", handleBookingPage(s.bs, s.hc))
|
|
private.PUT("/bookings/:id", handleBookingUpdate(s.bs, s.hc))
|
|
private.PATCH("/bookings/:id/cancel", handleBookingCancel(s.bs))
|
|
private.POST("/bookings/:id/items", handleCreateItem(s.bs, s.hc))
|
|
private.GET("/bookings/pdf/:id", handlePdfCreateInvoice(s.bs, s.hc))
|
|
|
|
private.POST("/items/:id", handleItemPay(s.bs))
|
|
private.PUT("/items/:id", handleItemUpdate(s.bs))
|
|
private.GET("/items/:id", handleLineItemForm(s.bs))
|
|
|
|
private.GET("/reports", handleReportsPage())
|
|
private.GET("/reports/do", handleReportCompute(s.bs, s.hc))
|
|
private.GET("/reports/pdf", handlePdfCreateReport(s.bs))
|
|
|
|
private.POST("/payments/:id", handleCreatePayment(s.bs))
|
|
private.PUT("/payments/:id", handlePaymentUpdate(s.bs))
|
|
private.GET("/payments/:id", handlePaymentForm(s.bs))
|
|
}
|