HTTPRouting
Endpoints
Map paths and HTTP methods to handlers.
http.Endpoints is the route mapping surface passed to
EndpointConfigurer.ConfigureEndpoints.
type Endpoints interface {
// MapAny maps a handler to a path for all HTTP methods.
MapAny(path string, handler Handler) *EndpointBuilder
// MapMethods maps a handler to a path for the selected HTTP methods.
MapMethods(path string, methods []Method, handler Handler) *EndpointBuilder
// MapGet maps a GET endpoint.
MapGet(path string, handler Handler) *EndpointBuilder
// MapPost maps a POST endpoint.
MapPost(path string, handler Handler) *EndpointBuilder
// MapPut maps a PUT endpoint.
MapPut(path string, handler Handler) *EndpointBuilder
// MapDelete maps a DELETE endpoint.
MapDelete(path string, handler Handler) *EndpointBuilder
// MapPatch maps a PATCH endpoint.
MapPatch(path string, handler Handler) *EndpointBuilder
// MapGroup creates a prefixed endpoint group.
MapGroup(prefix string) *EndpointGroup
}Use method-specific helpers for normal endpoints:
func (c *UserController) ConfigureEndpoints(endpoints http.Endpoints) {
endpoints.MapGet("/users/{id}", http.HandleResult(c.getUser))
endpoints.MapPost("/users", http.HandleResult(c.createUser))
endpoints.MapPatch("/users/{id}", http.HandleResult(c.updateUser))
endpoints.MapDelete("/users/{id}", http.Handle(c.deleteUser))
}Use MapMethods when one handler should respond to a selected set of methods:
endpoints.MapMethods(
"/health",
[]http.Method{http.MethodGet, http.MethodHead},
http.Handle(c.health),
)Each mapped route becomes an endpoint definition with a method, path pattern, and request delegate.
