Documentation
¶
Index ¶
- Constants
- Variables
- func Closest[T any](target string, items iter.Seq[T], key func(T) string) (match T, distance int, ok bool)
- func Handler(ctx fiber.Ctx) fiber.Handler
- func Operation(ctx fiber.Ctx) *api.Operation
- func Request(ctx fiber.Ctx) *api.Request
- func SetHandler(ctx fiber.Ctx, h fiber.Handler)
- func SetOperation(ctx fiber.Ctx, op *api.Operation)
- func SetRequest(ctx fiber.Ctx, req *api.Request)
- type BaseError
- type DuplicateError
- type NotFoundError
Constants ¶
View Source
const ( MetaKeyResource = "__resource" MetaKeyRESTHTTPMethod = "__http_method" MetaKeyRESTHTTPPath = "__http_path" AuthOptionRequiredPermission = "__required_permission" )
Variables ¶
View Source
var ( ErrResourceNil = errors.New("resource cannot be nil") ErrResourceNameEmpty = errors.New("resource name cannot be empty") ErrOperationNotFound = errors.New("operation not found") ErrOperationActionEmpty = errors.New("operation action cannot be empty") ErrNoRouterForKind = errors.New("no router can handle operation type") ErrNoRouterFound = errors.New("no router found") ErrNoHandlerResolverFound = errors.New("no handler resolver found") ErrNoHandlerAdapterFound = errors.New("no handler adapter found") ErrHandlerRequired = errors.New("handler is required for REST operations") ErrMethodNotFound = errors.New("api action method not found") ErrMethodAmbiguous = errors.New("api action method matches multiple methods") ErrHandlerInvalidReturnType = errors.New("handler method has invalid return type, must be 'error'") ErrHandlerTooManyReturns = errors.New("handler method has too many return values") ErrHandlerMustBeFunc = errors.New("provided handler must be a function") ErrHandlerNil = errors.New("provided handler function cannot be nil") )
Sentinel errors for API engine operations.
Functions ¶
func Closest ¶ added in v0.29.0
func Closest[T any](target string, items iter.Seq[T], key func(T) string) (match T, distance int, ok bool)
Closest finds the item whose projected key is nearest to target by Levenshtein distance. The returned distance is the minimum found. ok is false when items is empty or when two items tie for the minimum distance (an ambiguous match must not be suggested). Callers needing a proximity threshold should apply it to the returned distance themselves.
func Handler ¶ added in v0.28.0
Handler returns the resolved fiber.Handler stored in context by the RPC resolver.
func SetHandler ¶ added in v0.28.0
SetHandler stores the resolved fiber.Handler in the request context.
Types ¶
type BaseError ¶
type BaseError struct {
Identifier *api.Identifier
Err error
}
type DuplicateError ¶
func (*DuplicateError) Error ¶
func (e *DuplicateError) Error() string
type NotFoundError ¶
type NotFoundError struct {
BaseError
Suggestion *api.Identifier
}
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
Click to show internal directories.
Click to hide internal directories.