Turbo/Controller

// app/controllers/post_controller/postcontroller.go
package postcontroller

import (
	"net/http"

	"golazy.dev/lazycontroller"
)

func (c *PostsController) Update(post *Post, form *PostForm) error {
	updated, err := c.posts.Update(post.ID, form.Title)
	if err != nil {
		return err
	}
	c.Set("post", updated)
	return c.Wants(lazycontroller.Formats{
		lazycontroller.HTML: func() error {
			return c.RedirectToRoute("post", updated.ID, lazycontroller.RedirectStatus(http.StatusSeeOther))
		},
		lazycontroller.TurboFrame: func() error {
			return c.RenderTurboFrame("post")
		},
		lazycontroller.TurboStream: func() error {
			return c.Render("update")
		},
	})
}