{"modulePath":"github.com/theopenlane/core","version":"v1.34.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package route\n\nPackage route will hold the routes and route groups\n\n## Variables\n\n```go\nvar ErrAuthenticationRequired = errors.New(\"authentication required\")\n```\n\n## Functions\n\n```go\nfunc RegisterRoutes(router *Router) error\n```\nRegisterRoutes with the echo routers - Router is defined within openapi.go\n\n## Types\n\n```go\ntype Config struct {\n\t// Path is the route path pattern.\n\tPath string\n\t// Method is the HTTP method for the route.\n\tMethod string\n\t// Name is the OpenAPI summary for the route.\n\tName string\n\t// Description is the OpenAPI description for the route.\n\tDescription string\n\t// Tags are the OpenAPI tags for grouping.\n\tTags []string\n\t// OperationID is the OpenAPI operation ID.\n\tOperationID string\n\t// Security defines OpenAPI security requirements for the route.\n\tSecurity *openapi3.SecurityRequirements\n\t// Middlewares are applied before the handler.\n\tMiddlewares []echo.MiddlewareFunc\n\t// RateLimit applies a dedicated per-route rate limiter ahead of the route middleware when set and enabled.\n\tRateLimit *ratelimit.Config\n\t// Handler is the handler function wired into the route.\n\tHandler func(echo.Context) error\n\t// IncludeInOAS publishes this route in the OpenAPI specification. The\n\t// published surface is opt-in: only routes explicitly intended for\n\t// external consumers are documented, everything else stays private.\n\tIncludeInOAS bool\n\t// PublicCORS serves the route with a wildcard, credential-less CORS policy, for fully public\n\t// token-authorized endpoints called cross-origin from arbitrary domains (e.g. trust centers);\n\t// only supported for static paths (no path parameters)\n\tPublicCORS bool\n}\n```\nConfig holds the configuration for a route with automatic OpenAPI registration\n\n```go\ntype Router struct {\n\t// Echo is the underlying Echo router instance.\n\tEcho *echo.Echo\n\t// OAS is the OpenAPI spec being assembled.\n\tOAS *openapi3.T\n\t// Handler provides the HTTP handlers wired into routes.\n\tHandler *handlers.Handler\n\t// StartConfig holds Echo start configuration.\n\tStartConfig *echo.StartConfig\n\t// LocalFilePath points to static file roots for local assets.\n\tLocalFilePath string\n\t// Logger is the Echo logger used by the router.\n\tLogger *echo.Logger\n\t// SchemaRegistry registers and resolves OpenAPI schemas.\n\tSchemaRegistry handlers.SchemaRegistry\n\t// SpecInstances maps qualified model type names to instances for schema reflection; populated\n\t// from the generated instances file, only in spec-build mode\n\tSpecInstances map[string]any\n\t// SpecTypes accumulates every model type name the analyzed handlers need, used by the instance\n\t// emitter and to detect missing instances after registration\n\tSpecTypes map[string]bool\n}\n```\nRouter is a struct that holds the echo router, the OpenAPI schema, and the handler - it's a way to group these components together\n\n```go\nfunc (r *Router) AddEchoOnlyRoute(route echo.Routable) error\n```\nAddEchoOnlyRoute is used to add a route to the echo router without adding it to the OpenAPI schema\n\n```go\nfunc (r *Router) AddUnversionedHandlerRoute(config Config) error\n```\nAddUnversionedHandlerRoute adds a route to the base group and, in spec-build mode, its derived operation\n\n```go\nfunc (r *Router) AddV1HandlerRoute(config Config) error\n```\nAddV1HandlerRoute adds a route to the v1 group and, in spec-build mode, its derived operation\n\n```go\nfunc (r *Router) Base() *echo.Group\n```\nBase returns the base echo group - no \"version\" prefix for the router group\n\n```go\nfunc (r *Router) VersionOne() *echo.Group\n```\nVersionOne returns a new echo group for version 1 of the API\n\n```go\nfunc (r *Router) VersionTwo() *echo.Group\n```\nVersionTwo returns a new echo group for version 2 of the API - lets anticipate the future\n\n```go\ntype RouterOption func(*Router)\n```\nRouterOption is an option function that can be used to configure the router\n\n```go\nfunc WithEcho(e *echo.Echo) RouterOption\n```\nWithEcho is a RouterOption that allows the echo router to be set on the router\n\n```go\nfunc WithHandler(h *handlers.Handler) RouterOption\n```\nWithHandler is a RouterOption that allows the handler to be set on the router\n\n```go\nfunc WithHideBanner() RouterOption\n```\nWithHideBanner is a RouterOption that allows the banner to be hidden on the echo server\n\n```go\nfunc WithLocalFiles(lf string) RouterOption\n```\nWithLocalFiles is a RouterOption that allows the local files to be set on the router\n\n```go\nfunc WithLogger(logger *echo.Logger) RouterOption\n```\nWithLogger is a RouterOption that allows the logger to be set on the router\n\n```go\nfunc WithOptions(opts ...RouterOption) RouterOption\n```\nWithOptions is a RouterOption that allows multiple options to be set on the router\n\n","path":"github.com/theopenlane/core/internal/httpserve/route","name":"route","synopsis":"Package route will hold the routes and route groups","isRedistributable":true}
