mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
hx boost helper
This commit is contained in:
parent
3c31b142f6
commit
49dde76af6
2 changed files with 13 additions and 2 deletions
|
|
@ -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))
|
return renderTempl(c, http.StatusOK, view.BookingLines(bvm))
|
||||||
} else {
|
} else {
|
||||||
return renderTempl(c, http.StatusOK, view.ListBookings(bvm))
|
return renderTempl(c, http.StatusOK, view.ListBookings(bvm))
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func hxRedirect(c echo.Context, statusCode int, url string) error {
|
||||||
return c.NoContent(statusCode)
|
return c.NoContent(statusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isHxRequest(c echo.Context) bool {
|
func hxRequest(c echo.Context) bool {
|
||||||
header, ok := c.Request().Header["Hx-Request"]
|
header, ok := c.Request().Header["Hx-Request"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
|
|
@ -35,3 +35,14 @@ func isHxRequest(c echo.Context) bool {
|
||||||
}
|
}
|
||||||
return true
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue