shared

package
v0.29.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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

func Handler(ctx fiber.Ctx) fiber.Handler

Handler returns the resolved fiber.Handler stored in context by the RPC resolver.

func Operation

func Operation(ctx fiber.Ctx) *api.Operation

func Request

func Request(ctx fiber.Ctx) *api.Request

func SetHandler added in v0.28.0

func SetHandler(ctx fiber.Ctx, h fiber.Handler)

SetHandler stores the resolved fiber.Handler in the request context.

func SetOperation

func SetOperation(ctx fiber.Ctx, op *api.Operation)

func SetRequest

func SetRequest(ctx fiber.Ctx, req *api.Request)

Types

type BaseError

type BaseError struct {
	Identifier *api.Identifier
	Err        error
}

func (*BaseError) Error

func (e *BaseError) Error() string

func (*BaseError) Unwrap

func (e *BaseError) Unwrap() error

Unwrap returns the underlying error, allowing errors.As and errors.Is to work correctly.

type DuplicateError

type DuplicateError struct {
	BaseError

	Existing *api.Operation
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL