mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-10 20:56:50 +00:00
fix search bug introduce isHxRequest helper
This commit is contained in:
parent
e02de4daa5
commit
701a32671a
2 changed files with 12 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ func handleBookingListPage(bs *booking.Service, hc *config.Host) echo.HandlerFun
|
|||
}
|
||||
})
|
||||
|
||||
if search != "" {
|
||||
if isHxRequest(c) {
|
||||
return renderTempl(c, http.StatusOK, view.BookingLines(bvm))
|
||||
} else {
|
||||
return renderTempl(c, http.StatusOK, view.ListBookings(bvm))
|
||||
|
|
|
|||
|
|
@ -24,3 +24,14 @@ func hxRedirect(c echo.Context, statusCode int, url string) error {
|
|||
c.Response().Header().Add("HX-Redirect", url)
|
||||
return c.NoContent(statusCode)
|
||||
}
|
||||
|
||||
func isHxRequest(c echo.Context) bool {
|
||||
header, ok := c.Request().Header["Hx-Request"]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if header[0] != "true" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue