Skip to content

v0.3.7

Compare
Choose a tag to compare
@maddalax maddalax released this 20 Oct 15:28
· 180 commits to master since this release
  1. 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 
  1. Fixed bug with HxOnMutationError

  2. 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)),
	)
}
  1. 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.

  2. Added h.EmptyPage() to return a blank page