v2

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package v2 resolves legacy API routes only from verified, installed package artifacts. It deliberately has no dependency on the design-time catalog.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRouteNotDeclared   = errors.New("v2 package route is not declared")
	ErrPackageUnavailable = errors.New("v2 package route is unavailable")
)

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	Dispatch(context.Context, pluginhost.DispatchInput) (pluginhost.DispatchOutput, error)
}

type Envelope

type Envelope string
const (
	EnvelopeData      Envelope = "data"
	EnvelopePanel     Envelope = "panel"
	EnvelopeRaw       Envelope = "raw"
	EnvelopeWebSocket Envelope = "websocket"
)

type Gateway

type Gateway struct {
	Registry         *Registry
	Dispatcher       Dispatcher
	Timeout          time.Duration
	RequestBodyLimit int64
}

Gateway is the unary v2 compatibility boundary. It has no legacy handler fallback: a route must resolve from an active, verified package artifact.

func (Gateway) Serve

func (g Gateway) Serve(c *gin.Context)

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(source RouteSource) *Registry

func (*Registry) Resolve

func (r *Registry) Resolve(method, normalizedPath string) (Route, bool)

Resolve is a boolean convenience API for router registration and callers that do not need an error class. Gateways use ResolveContext to preserve fail-closed status mapping.

func (*Registry) ResolveContext

func (r *Registry) ResolveContext(ctx context.Context, method, requestPath string) (Route, error)

type Route

type Route struct {
	Method       string
	LegacyPath   string
	PackageID    string
	Version      string
	PackageRoute string
	Envelope     Envelope
	Generation   uint64
	Transport    Transport
}

Route is a request-time route authorization bound to one verified package release and one running installation generation.

func (Route) Validate

func (r Route) Validate() error

type RouteSource

type RouteSource interface {
	ResolveV2Route(context.Context, string, string) (Route, error)
}

RouteSource performs the trusted, request-time route lookup.

func NewVerifiedRouteSource

func NewVerifiedRouteSource(db *gorm.DB, encodedPublicKey string) RouteSource

NewVerifiedRouteSource creates the production resolver. An invalid trust root is retained as a fail-closed resolver error rather than falling back to any source-derived catalog entry.

type Transport

type Transport string
const (
	TransportHTTP      Transport = "http"
	TransportWebSocket Transport = "websocket"
)

type WebSocketGateway

type WebSocketGateway struct {
	Registry       *Registry
	Dispatcher     pluginhost.WebSocketManager
	Timeout        time.Duration
	SessionTimeout time.Duration
	Upgrade        WebSocketUpgrade
}

WebSocketGateway resolves and opens a package relay before accepting the browser upgrade. Legacy socket handlers are intentionally not reachable.

func (WebSocketGateway) Serve

func (g WebSocketGateway) Serve(c *gin.Context)

func (WebSocketGateway) ServeHTTP

func (g WebSocketGateway) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP is useful for non-Gin integration points and keeps resolution before upgrade testable without a real WebSocket connection.

type WebSocketUpgrade

type WebSocketUpgrade func(http.ResponseWriter, *http.Request, http.Header) (*websocket.Conn, error)

Jump to

Keyboard shortcuts

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