Documentation
¶
Overview ¶
Package restroute matches REST-JSON requests against smithy-style URI templates and writes AWS REST-JSON errors.
Index ¶
- func EscapedPath(r *http.Request) string
- func MaxResultsQuery(q url.Values, name string) (int, error)
- func Paginate[T any](all []T, token string, maxResults, defaultLimit, maxAllowed int) (page.Page[T], error)
- func WriteError(c *echo.Context, status int, code, message string, extra map[string]any) error
- type Error
- type OpFunc
- type Request
- type Route
- type Router
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapedPath ¶
EscapedPath returns the request path with percent-encoding preserved (labels may contain "/").
func MaxResultsQuery ¶
MaxResultsQuery parses an optional integer query parameter; absent yields 0.
Types ¶
type Error ¶
Error is an AWS REST-JSON exception: HTTP status, error code, message and optional extra body members.
func QuotaExceeded ¶
QuotaExceeded builds a 402 ServiceQuotaExceededException.
func Validation ¶
Validation builds a 400 ValidationException.
type OpFunc ¶
OpFunc runs one operation. A nil result is sent as an empty object; a zero status means 200.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router resolves requests to operations; the zero value matches nothing.
type Server ¶
type Server struct {
Router *Router
Ops map[string]OpFunc
// Context derives the per-request context (region, caller identity, ...); nil uses the request context.
Context func(r *http.Request) context.Context
}
Server dispatches matched requests to OpFuncs.
func (*Server) Handler ¶
func (s *Server) Handler() echo.HandlerFunc
Handler serves a request: route, read body, run the op, write JSON or the mapped error.