Documentation
¶
Index ¶
- func NewAuthProxy(serviceName, targetURL string, local bool, gatewayURL string, fortName string) http.Handler
- func NewHandler(fort domain.Fort, tracker *ServiceTracker, tc *TokenConverter, spaFS fs.FS) http.Handler
- func NewSPADevProxy(devURL string) http.Handler
- func NewSPAHandler(fsys fs.FS) http.Handler
- func NewServiceProxy(serviceName, targetURL string, local bool, gatewayURL string) http.Handler
- func NewWSProxy(backendURL string, wsPaths []string, serviceName string, ...) http.Handler
- type Conflict
- type ConnectionCallbacks
- type FortInstance
- type FortRouter
- type ServiceTracker
- func (t *ServiceTracker) Conflicts() []Conflict
- func (t *ServiceTracker) InitialProbe(ctx context.Context)
- func (t *ServiceTracker) OnConnect(name string)
- func (t *ServiceTracker) OnDisconnect(name string)
- func (t *ServiceTracker) ServiceByName(name string) (TrackedService, bool)
- func (t *ServiceTracker) Services() []TrackedService
- func (t *ServiceTracker) StartPolling(ctx context.Context, interval time.Duration)
- type TokenConverter
- type TrackedService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAuthProxy ¶
func NewAuthProxy(serviceName, targetURL string, local bool, gatewayURL string, fortName string) http.Handler
NewAuthProxy creates a reverse proxy for auth that rewrites Set-Cookie paths to scope cookies to the fort's URL prefix.
func NewHandler ¶
func NewHandler(fort domain.Fort, tracker *ServiceTracker, tc *TokenConverter, spaFS fs.FS) http.Handler
NewHandler creates the top-level HTTP handler for the web shell.
Parameters:
- fort: the active fort configuration
- tracker: live service tracker (health probing + WS connection tracking)
- tc: token converter for BFF auth (nil disables BFF — only shell endpoints and SPA work)
- spaFS: embedded SPA filesystem (nil disables SPA serving — use NewSPADevProxy for dev mode)
func NewSPADevProxy ¶
NewSPADevProxy returns a handler that proxies all requests to a Vite dev server. Used with the --dev flag.
func NewSPAHandler ¶
NewSPAHandler serves an embedded SPA filesystem. Requests for real files are served directly. All other paths fall back to index.html for client-side routing.
func NewServiceProxy ¶
NewServiceProxy creates an http.Handler that proxies requests to a service.
For local forts (local=true): strips the /api/{serviceName} prefix and forwards to the targetURL (e.g., /api/nexus/v1/vms -> http://target/v1/vms).
For gateway forts (local=false): preserves the /api/{serviceName} prefix and forwards to the gatewayURL.
func NewWSProxy ¶
func NewWSProxy(backendURL string, wsPaths []string, serviceName string, cb *ConnectionCallbacks) http.Handler
NewWSProxy creates an http.Handler that proxies WebSocket connections to a backend service. Only paths in wsPaths are allowed — others return 400.
The serviceName is used to strip the /api/{service} prefix before matching. The backendURL is the base WebSocket URL of the service (e.g., "ws://127.0.0.1:16000").
Types ¶
type Conflict ¶
type Conflict struct {
URL string `json:"url"`
Name string `json:"name"`
Reason string `json:"reason"`
}
Conflict records a service that was excluded due to a collision.
type ConnectionCallbacks ¶
type ConnectionCallbacks struct {
OnConnect func(service string)
OnDisconnect func(service string)
}
ConnectionCallbacks notifies the caller of WebSocket connection lifecycle events.
type FortInstance ¶
type FortInstance struct {
// contains filtered or unexported fields
}
type FortRouter ¶
type FortRouter struct {
// contains filtered or unexported fields
}
func NewFortRouter ¶
func NewFortRouter(registry domain.FortRegistry, spaHandler http.Handler) *FortRouter
func (*FortRouter) ServeHTTP ¶
func (fr *FortRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*FortRouter) StartIdleCleanup ¶
func (fr *FortRouter) StartIdleCleanup(ctx context.Context, maxIdle time.Duration)
type ServiceTracker ¶
type ServiceTracker struct {
// OnServiceDiscovered is called when a new service is discovered after
// the initial probe. Called WITHOUT holding the mutex.
OnServiceDiscovered func(svc TrackedService)
// contains filtered or unexported fields
}
ServiceTracker maintains live state for all services via health probing and WebSocket connection tracking.
func NewServiceTracker ¶
func NewServiceTracker(urls []string) *ServiceTracker
NewServiceTracker creates a tracker for the given service URLs.
func (*ServiceTracker) Conflicts ¶
func (t *ServiceTracker) Conflicts() []Conflict
Conflicts returns a snapshot of all detected conflicts.
func (*ServiceTracker) InitialProbe ¶
func (t *ServiceTracker) InitialProbe(ctx context.Context)
InitialProbe runs a synchronous probe of all services in config order. Sequential so conflict resolution is deterministic (first in config wins).
func (*ServiceTracker) OnConnect ¶
func (t *ServiceTracker) OnConnect(name string)
OnConnect increments the WS connection ref count for a service.
func (*ServiceTracker) OnDisconnect ¶
func (t *ServiceTracker) OnDisconnect(name string)
OnDisconnect decrements the WS connection ref count for a service.
func (*ServiceTracker) ServiceByName ¶
func (t *ServiceTracker) ServiceByName(name string) (TrackedService, bool)
ServiceByName returns a discovered service by name, or false if not found.
func (*ServiceTracker) Services ¶
func (t *ServiceTracker) Services() []TrackedService
Services returns a snapshot of all discovered services.
func (*ServiceTracker) StartPolling ¶
func (t *ServiceTracker) StartPolling(ctx context.Context, interval time.Duration)
StartPolling begins background health probing on the given interval.
type TokenConverter ¶
type TokenConverter struct {
// contains filtered or unexported fields
}
TokenConverter converts session cookies to JWTs by calling the auth service.
func NewTokenConverter ¶
func NewTokenConverter(authServiceURL string) *TokenConverter
NewTokenConverter creates a token converter that calls authServiceURL to exchange session cookies for JWTs.
func NewTokenConverterForTest ¶
func NewTokenConverterForTest(authServiceURL string, ttl, refresh time.Duration) *TokenConverter
NewTokenConverterForTest creates a converter with custom timing parameters.
func (*TokenConverter) CacheLen ¶ added in v0.3.0
func (tc *TokenConverter) CacheLen() int
CacheLen returns the number of cached tokens (for testing).
type TrackedService ¶
type TrackedService struct {
URL string `json:"-"`
Name string `json:"name"`
Label string `json:"label"`
Route string `json:"route"`
Enabled bool `json:"enabled"`
UI bool `json:"ui"`
Connected bool `json:"connected"`
SetupMode bool `json:"setup_mode,omitempty"`
WSPaths []string `json:"-"`
// contains filtered or unexported fields
}
TrackedService is the live state of a discovered service.