Basically I want to be able using echo to return from a post request either an error that then gets swapped into the hx-target on error or when no error occurs redirect to the user page. However this doesn't work as the content of the user page just gets rendered inside the hx-target paragraph. Maybe somebody has a workaround or better idea on how to implement this than I do.
I have a handler function similar to this that is mapped to post /auth/register
func (h AuthHandler) HandleRegister(c echo.Context) error {
// Perform the registration
if err != nil {
return err
}
return c.Redirect(http.StatusMovedPermanently, "/user")
}
this is called here:
<form hx-post="/auth/register" hx-trigger="submit" hx-target="#error" class="">
<label for="email">Email</label>
<input type="email" name="email">
<label for="password">Password</label>
<input type="password" name="password">
<label for="confirm-password">Confirm Password</label>
<input type="password" name="confirm-password">
<p id="error"></p>
<button type="submit">Register</button>
</form>