{"modulePath":"github.com/osapi-io/osapi","version":"v0.2.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\nPackage api provides the REST API server and handler registration.\n\n## Constants\n\n```go\nconst (\n\tContextKeySubject = \"auth.subject\"\n\tContextKeyRoles   = \"auth.roles\"\n)\n```\nContext key constants for injecting user identity into handlers.\n\n## Types\n\n```go\ntype Option func(*Server)\n```\nOption is a functional option for configuring the Server.\n\n```go\nfunc WithAuditStore(\n\tstore audit.Store,\n) Option\n```\nWithAuditStore sets the audit store for audit middleware.\n\n```go\nfunc WithMeterProvider(\n\tmp *sdkmetric.MeterProvider,\n) Option\n```\nWithMeterProvider sets the OTEL MeterProvider for HTTP metrics. When set, the otelecho middleware routes metrics to this provider instead of the global provider.\n\n```go\ntype Server struct {\n\tEcho *echo.Echo\n\t// contains filtered or unexported fields\n}\n```\nServer implementation of the Server's API operations.\n\n```go\nfunc New(\n\tappConfig config.Config,\n\tlogger *slog.Logger,\n\topts ...Option,\n) *Server\n```\nNew initialize a new Server and configure an Echo server.\n\n```go\nfunc (s *Server) RegisterHandlers(\n\thandlers []func(e *echo.Echo),\n)\n```\nRegisterHandlers registers a list of handlers with the Echo instance.\n\n```go\nfunc (s *Server) Start()\n```\nStart starts the Echo server with the configured port.\n\n```go\nfunc (s *Server) Stop(\n\t_ context.Context,\n)\n```\nStop gracefully shuts down the Echo server. Stop asks the server to drain and returns without waiting for it.\n\nCancelling is what starts the drain; StartConfig.GracefulTimeout bounds how long Echo waits, and the goroutine in Start reports the outcome. A caller must not treat this returning as \"every in-flight request finished\" — the only caller, cli.RunServer, then runs cleanup within its own budget, which is what bounds the process rather than this call.\n\nThe context is unused for the same reason: there is nothing here to cancel.\n\n```go\ntype StrictHandlerFunc func(ctx *echo.Context, request any) (any, error)\n```\nStrictHandlerFunc is the shape oapi-codegen's strict handlers take under Echo v5. Each generated package declares its own identical type, so a helper shared across packages cannot name any one of them. Declaring it once here gives the shared middleware a type to sit on; call sites convert to and from their own package's version, which Go permits because the underlying signatures match.\n\n```go\nfunc ScopeMiddleware(\n\thandler StrictHandlerFunc,\n\ttokenManager TokenValidator,\n\tsigningKey string,\n\tcontextKey string,\n\tcustomRoles map[string][]string,\n) StrictHandlerFunc\n```\nScopeMiddleware validates JWT tokens and checks for required permissions.\n\n```go\ntype TokenValidator interface {\n\tValidate(\n\t\ttokenString string,\n\t\tsigningKey string,\n\t) (*authtoken.CustomClaims, error)\n}\n```\nTokenValidator parses and validates JWT tokens.\n\n","path":"github.com/osapi-io/osapi/internal/controller/api","name":"api","synopsis":"Package api provides the REST API server and handler registration.","isRedistributable":true}
