mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/labstack/echo/v4/middleware"
|
|
|
|
"github.com/rjNemo/rentease/constants"
|
|
)
|
|
|
|
func (s Server) MountHandlers() {
|
|
// config
|
|
s.Router.HideBanner = true
|
|
s.Router.Debug = strings.ToLower(os.Getenv("DEBUG")) == "true"
|
|
s.Router.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
|
Format: "${time_rfc3339} [${method}: ${status}] ${uri}; ip=${remote_ip}; ${latency_human}; ${user_agent}\n",
|
|
}))
|
|
s.Router.HTTPErrorHandler = s.customHTTPErrorHandler
|
|
// middlewares
|
|
s.Router.Use(middleware.Recover())
|
|
s.Router.Use(middleware.Secure())
|
|
// static assets
|
|
s.Router.Static("/static", "assets")
|
|
// landing page
|
|
s.Router.GET("/", handleHomePage())
|
|
s.Router.GET("/bookings", handleListBookingPage(s.bs))
|
|
s.Router.GET("/bookings/new", handleNewBookingPage())
|
|
s.Router.POST("/bookings/new", handleCreateBooking(s.bs))
|
|
s.Router.GET("/bookings/:id", handleBookingPage(s.bs))
|
|
s.Router.POST(fmt.Sprintf("%s/:id/items", constants.RouteBooking), s.handleCreateItem())
|
|
s.Router.GET("/reports", handleReportsPage())
|
|
s.Router.GET("/reports/do", handleComputeReport(s.bs))
|
|
s.Router.GET("/pdf", handleCreateInvoicePdf(s.ps))
|
|
}
|