controllers

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package controllers contains application-owned HTTP handlers. Controllers should translate HTTP input and output while delegating business logic to services; keep each feature in a descriptive file such as invoice_controller.go.

A basic controller has one service dependency, a constructor and small Echo handlers. Business logic belongs in the service:

type InvoiceService interface {
	List(context.Context) ([]models.InvoiceResponse, error)
}

type InvoiceController struct {
	service InvoiceService
}

func NewInvoiceController(service InvoiceService) *InvoiceController {
	return &InvoiceController{service: service}
}

func (c *InvoiceController) List(ec echo.Context) error {
	invoices, err := c.service.List(ec.Request().Context())
	if err != nil {
		return apierr.Reply(ec, err)
	}
	return ec.JSON(http.StatusOK, invoices)
}

Register the handler in routes.go. For a complete generated implementation, run: procyon-cli module create invoice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HelloController

type HelloController struct {
	// contains filtered or unexported fields
}

func NewHelloController

func NewHelloController(appService *services.AppService, logger *zap.Logger) *HelloController

func (*HelloController) Health

func (c *HelloController) Health(ec echo.Context) error

func (*HelloController) Hello

func (c *HelloController) Hello(ec echo.Context) error

func (*HelloController) HelloAdmin

func (c *HelloController) HelloAdmin(ec echo.Context) error

func (*HelloController) HelloAuthenticated

func (c *HelloController) HelloAuthenticated(ec echo.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL