hx boost helper

This commit is contained in:
Ruidy 2024-09-09 22:34:29 +02:00
parent 3c31b142f6
commit 49dde76af6
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
2 changed files with 13 additions and 2 deletions

View file

@ -45,7 +45,7 @@ func handleBookingListPage(bs *booking.Service, hc *config.Host) echo.HandlerFun
}
})
if isHxRequest(c) {
if hxRequest(c) && !hxBoosted(c) {
return renderTempl(c, http.StatusOK, view.BookingLines(bvm))
} else {
return renderTempl(c, http.StatusOK, view.ListBookings(bvm))

View file

@ -25,7 +25,7 @@ func hxRedirect(c echo.Context, statusCode int, url string) error {
return c.NoContent(statusCode)
}
func isHxRequest(c echo.Context) bool {
func hxRequest(c echo.Context) bool {
header, ok := c.Request().Header["Hx-Request"]
if !ok {
return false
@ -35,3 +35,14 @@ func isHxRequest(c echo.Context) bool {
}
return true
}
func hxBoosted(c echo.Context) bool {
header, ok := c.Request().Header["Hx-Boosted"]
if !ok {
return false
}
if header[0] != "true" {
return false
}
return true
}