Controllers/Generators

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

import (
	"fmt"
	"net/http"

	"golazy.dev/lazycontroller"
)

type Post struct {
	ID    int
	Title string
}

func (c *PostsController) GenPost(postID int) (*Post, error) {
	post, err := c.posts.Find(postID)
	if err != nil {
		return nil, lazycontroller.Error(http.StatusNotFound, fmt.Errorf("post not found"))
	}
	return post, nil
}

func (c *PostsController) Show(post *Post) error {
	c.Set("post", post)
	return nil
}