Documentation
¶
Overview ¶
Package api provides the REST API server and handler registration.
Index ¶
Constants ¶
const ( ContextKeySubject = "auth.subject" ContextKeyRoles = "auth.roles" ContextKeyTargets = "auth.targets" )
Context key constants for injecting user identity into handlers.
const ( SelfSignedCert = "api.crt" SelfSignedKey = "api.key" )
The files of the self-signed certificate in controller.pki.key_dir.
Variables ¶
This section is empty.
Functions ¶
func CertFingerprint ¶ added in v0.3.0
CertFingerprint is the SHA-256 of the certificate that the API serves, as SHA256:<hex>, which a join token pins: the certificate of c, or the self-signed one in keyDir.
func TLSConfig ¶ added in v0.3.0
TLSConfig is the server's TLS config: the certificate of c, or the self-signed certificate in keyDir, which it makes when it does not exist. A certificate that c names later replaces the self-signed one with no other change. The server reads the files again when they change, at the next handshake: a rotated certificate takes effect with no restart.
Types ¶
type Option ¶
type Option func(*Server)
Option is a functional option for configuring the Server.
func WithAuditStore ¶
WithAuditStore sets the audit store for audit middleware.
func WithMeterProvider ¶
func WithMeterProvider( mp *sdkmetric.MeterProvider, ) Option
WithMeterProvider sets the OTEL MeterProvider for HTTP metrics. When set, the otelecho middleware routes metrics to this provider instead of the global provider.
type Server ¶
Server implementation of the Server's API operations.
func (*Server) RegisterHandlers ¶
RegisterHandlers registers a list of handlers with the Echo instance.
func (*Server) Start ¶
func (s *Server) Start()
Start starts the Echo server on the configured host and port. An empty host binds every interface.
func (*Server) Stop ¶
Stop gracefully shuts down the Echo server. Stop asks the server to drain and returns without waiting for it.
Cancelling 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 start command then runs the cleanups within one shutdown budget. That budget bounds the process, not this call.
The context is unused for the same reason: there is nothing here to cancel.
type StrictHandlerFunc ¶
StrictHandlerFunc 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.
func ScopeMiddleware ¶
func ScopeMiddleware( handler StrictHandlerFunc, tokenManager TokenValidator, signingKeys authtoken.Keys, contextKey string, customRoles authtoken.CustomRoles, ) StrictHandlerFunc
ScopeMiddleware validates JWT tokens and checks for required permissions.
type TokenValidator ¶
type TokenValidator interface {
Validate(
tokenString string,
keys authtoken.Keys,
) (*authtoken.CustomClaims, error)
}
TokenValidator parses and validates JWT tokens.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apierr answers, in one place, which HTTP status a failed job deserves.
|
Package apierr answers, in one place, which HTTP status a failed job deserves. |
|
Package ui provides the HTTP handler for serving the embedded React UI.
|
Package ui provides the HTTP handler for serving the embedded React UI. |