Documentation
¶
Overview ¶
Package endpoints provides types and utilities for defining and registering HTTP endpoints.
Use this package when building HTTP APIs that require structured endpoint path registration with validation. It enables grouping middleware with handlers, validating endpoint paths at registration time, and organizing endpoints through a builder pattern.
The package supports parameterized paths using curly brace syntax (e.g., "/users/{id}") and validates that paths follow correct formatting conventions. Types implementing the EndpointHandler interface can register their endpoints with a shared builder, making it easy to compose endpoints from multiple sources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used in the EndpointHandler's visitor to set paths to handlers.
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder allocates and sets default values in a Builder.
func (*Builder) MustRegister ¶
MustRegister assigns a Path and Method to a Endpoint. This function does validation to ensure duplicates are not registered. If the path and method is already registered, this function panics.
type Endpoint ¶
type Endpoint struct {
Middleware []middleware.Middleware
Handler http.HandlerFunc
}
Endpoint encapsulates middleware and an HTTP handler for request processing.
type EndpointHandler ¶
type EndpointHandler interface {
RegisterEndpoints(builder *Builder)
}
EndpointHandler is implemented by types that register HTTP endpoints.