Procyon|Docs
HTTPRouting

Configure Routes

Configure HTTP endpoints from regular Procyon components.

Routes are configured by components that implement http.EndpointConfigurer. The runtime collects those components and gives them an http.Endpoints registry during web startup.

endpoint_configurer.go
type EndpointConfigurer interface {
	// ConfigureEndpoints maps routes into the HTTP endpoint registry.
	ConfigureEndpoints(endpoints Endpoints)
}

Use this interface on controllers or route modules:

users.go
type UserController struct {
	service *UserService
}

func NewUserController(service *UserService) *UserController {
	return &UserController{service: service}
}

func (c *UserController) ConfigureEndpoints(endpoints http.Endpoints) {
	endpoints.MapGet("/users/{id}", http.HandleResult(c.getUser))
	endpoints.MapPost("/users", http.HandleResult(c.createUser))
}

The controller is still a component, so its dependencies belong in the constructor. Route mapping stays close to the handlers that own the behavior.