mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
use naming convention for hamndlers
naming convention
This commit is contained in:
parent
2c1c4fdafb
commit
25e48b03f9
3 changed files with 14 additions and 14 deletions
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/rjNemo/rentease/internal/pdf"
|
||||
)
|
||||
|
||||
func handleCreateInvoicePdf(bs *booking.Service, ps *pdf.PdfService, hc *config.Host) echo.HandlerFunc {
|
||||
func handlePdfCreateInvoice(bs *booking.Service, ps *pdf.PdfService, hc *config.Host) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
idStr := c.Param("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
|
|
@ -31,7 +31,7 @@ func handleCreateInvoicePdf(bs *booking.Service, ps *pdf.PdfService, hc *config.
|
|||
}
|
||||
}
|
||||
|
||||
func handleCreateReportPdf(bs *booking.Service, ps *pdf.PdfService) echo.HandlerFunc {
|
||||
func handlePdfCreateReport(bs *booking.Service, ps *pdf.PdfService) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
period := c.QueryParam("period")
|
||||
if !u.Contains([]string{"month", "year"}, period) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func handleReportsPage() echo.HandlerFunc {
|
|||
}
|
||||
}
|
||||
|
||||
func handleComputeReport(bs *booking.Service, hc *config.Host) echo.HandlerFunc {
|
||||
func handleReportCompute(bs *booking.Service, hc *config.Host) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
period := c.FormValue("period")
|
||||
if !u.Contains([]string{"month", "year"}, period) {
|
||||
|
|
|
|||
|
|
@ -19,25 +19,25 @@ func (s Server) MountHandlers() {
|
|||
api.Use(middleware.KeyAuthWithConfig(middleware.KeyAuthConfig{
|
||||
KeyLookup: "header:api-key",
|
||||
Validator: func(key string, c echo.Context) (bool, error) {
|
||||
return key == s.apiKey, nil
|
||||
return s.as.ValidateApiKey(key), nil
|
||||
},
|
||||
}))
|
||||
api.POST("/sync", handleSync(s.bs))
|
||||
// admin
|
||||
g := s.Router.Group("")
|
||||
g.Use(MakeAuthMiddleware())
|
||||
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", handleBookingListPage(s.bs, s.hc))
|
||||
g.GET("/bookings/new", handleBookingCreatePage(s.hc))
|
||||
g.POST("/bookings/new", handleBookingCreate(s.bs))
|
||||
g.GET("/bookings/:id", handleBookingPage(s.bs, s.hc))
|
||||
g.PUT("/bookings/:id", handleUpdateBooking(s.bs, s.hc))
|
||||
g.PATCH("/bookings/:id/cancel", handleCancelBooking(s.bs))
|
||||
g.PUT("/bookings/:id", handleBookingUpdate(s.bs, s.hc))
|
||||
g.PATCH("/bookings/:id/cancel", handleBookingCancel(s.bs))
|
||||
g.POST("/bookings/:id/items", handleCreateItem(s.bs))
|
||||
g.POST("/items/:id", handlePayItem(s.bs))
|
||||
g.PUT("/items/:id", handleUpdateItem(s.bs))
|
||||
g.POST("/items/:id", handleItemPay(s.bs))
|
||||
g.PUT("/items/:id", handleItemUpdate(s.bs))
|
||||
g.GET("/items/:id", handleLineItemForm(s.bs))
|
||||
g.GET("/bookings/pdf/:id", handleCreateInvoicePdf(s.bs, s.ps, s.hc))
|
||||
g.GET("/bookings/pdf/:id", handlePdfCreateInvoice(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))
|
||||
g.GET("/reports/do", handleReportCompute(s.bs, s.hc))
|
||||
g.GET("/reports/pdf", handlePdfCreateReport(s.bs, s.ps))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue