Routes

// init/routes.go
package appinit

import (
	"golazy.dev/lazyroutes"
	homecontroller "sample_app/app/controllers/home_controller"
	postcontroller "sample_app/app/controllers/post_controller"
)

func Draw(router *lazyroutes.Scope) {
	router.Resources(homecontroller.New, func(home *lazyroutes.Resource) {
		home.Singular("home")
		home.Plural("home")
		home.Path("")
	})

	// Resources registers only the conventional actions implemented by the controller.
	router.Resources(postcontroller.New, func(posts *lazyroutes.Resource) {
		// Keep resource-specific operations inside the resource declaration.
		posts.Get("search", (*postcontroller.PostsController).Search)
		posts.MemberPatch("publish", (*postcontroller.PostsController).Publish)
	})
}