mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +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))
|
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))
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,14 @@ func hxRedirect(c echo.Context, statusCode int, url string) error {
|
||||||
c.Response().Header().Add("HX-Redirect", url)
|
c.Response().Header().Add("HX-Redirect", url)
|
||||||
return c.NoContent(statusCode)
|
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