Skip to content
1.5.2
The Basics / 1.5.2

Controllers

Controllers receive Echo requests, coordinate application work, and return HTML, Inertia, JSON, redirects, or errors.

Register handlers

A controller exposes RegisterRoutes and is connected through the controllers Fx module. Keep request parsing and response decisions at this boundary.

Render HTML

Use the hypermedia helpers for Templ pages and fragments:

1func (p Products) Index(etx *echo.Context) error {
2    products, err := p.models.All(etx.Request().Context())
3    if err != nil {
4        return err
5    }
6    return hypermedia.RenderPage(etx, views.ProductsIndex(products))
7}

Generate controllers

Generate a complete resource controller or selected actions:

1andurel generate controller Product
2andurel generate controller Product index show
3andurel generate controller Dashboard overview

Use --api for JSON controllers and --inertia for pages using the configured Inertia adapter.

Documentation

Start typing to search the documentation.