v0.3.7
- Added a few helper methods to h.RequestContext
// redirect to a specific location
func (c *RequestContext) Redirect(path string, code int)
// set cookie
func (c *RequestContext) SetCookie(cookie *http.Cookie)
func (c *RequestContext) IsHttpPost() bool
func (c *RequestContext) IsHttpGet() bool
func (c *RequestContext) IsHttpPut() bool
func (c *RequestContext) IsHttpDelete() bool
-
Fixed bug with
HxOnMutationError
-
Added support for returning 'nil' in page or partials. This allows you to write your own response (such as redirecting), without having to return a page or partial, just return nil
Usage:
func IndexPage(ctx *h.RequestContext) *h.Page {
u, ok := user.GetUserOrRedirect(ctx)
if !ok {
return nil
}
return h.NewPage(
RootPage(UserProfilePage(u)),
)
}
-
Updated htmx to swap content if the http status code is 400 or 422. It normally does not do this by default but it is important to show error messages in the case of 400's. Generally 400's are from our own code, so we should be to control what gets swapped in and show proper error messages.
-
Added
h.EmptyPage()
to return a blank page