handlers

package
v0.27.7 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: CC0-1.0 Imports: 29 Imported by: 0

Documentation

Overview

Package handlers binds the Connect-generated service interfaces to the prosa internal/server services (auth, sessions, devices).

Package handlers ships a plain HTTP SSE endpoint /sse/events that forwards Postgres NOTIFY events on channel "prosa.session.changed". This lives outside Connect because Connect's streaming surface isn't SSE-friendly enough to justify the wrapper; raw HTTP + EventSource on the browser side is simpler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyticsHandler

type AnalyticsHandler struct {
	prosav1connect.UnimplementedAnalyticsServiceHandler
	Pool *pgxpool.Pool
}

AnalyticsHandler implements AnalyticsService against Postgres. The CLI-facing reports (subagents included) mirror internal/store/analytics.go (which targets SQLite), rewritten with $N placeholders and tsvector FTS in place of FTS5. The remaining insights reports feed the panel only, with no SQLite mirror.

func NewAnalyticsHandler

func NewAnalyticsHandler(pool *pgxpool.Pool) *AnalyticsHandler

func (*AnalyticsHandler) GetReport

GetReport dispatches by report name.

type AuthHandler

type AuthHandler struct {
	prosav1connect.UnimplementedAuthServiceHandler
	Svc *auth.Service
}

AuthHandler is the Connect implementation backed by *auth.Service.

func NewAuthHandler

func NewAuthHandler(svc *auth.Service) *AuthHandler

type DevicesHandler

type DevicesHandler struct {
	prosav1connect.UnimplementedDevicesServiceHandler
	Pool *pgxpool.Pool
}

DevicesHandler implements the DevicesService Connect interface.

func NewDevicesHandler

func NewDevicesHandler(pool *pgxpool.Pool) *DevicesHandler

func (*DevicesHandler) List

List returns every device row known to the server. Revoked devices are included with the revoked field set so the panel can show them dimmed; clients usually filter.

func (*DevicesHandler) Rename

Rename sets devices.friendly_name. Accepts id="self" → caller's id. Device callers can only rename themselves; owner callers (panel) may rename any device.

func (*DevicesHandler) Revoke

Revoke marks all device_tokens for the target as revoked and stamps devices.revoked_at. Device callers can only revoke themselves; owner callers (panel) may revoke any device.

type PreferencesHandler

type PreferencesHandler struct {
	prosav1connect.UnimplementedPreferencesServiceHandler
	Pool *pgxpool.Pool
}

PreferencesHandler implements the PreferencesService Connect interface. Only owner callers (the panel, authenticated via the admin token) may read or write; the owner_email in the request scopes the rows.

func NewPreferencesHandler

func NewPreferencesHandler(pool *pgxpool.Pool) *PreferencesHandler

func (*PreferencesHandler) Get

Get returns every stored preference for the owner as a key/value map.

func (*PreferencesHandler) Set

Set upserts one preference for the owner. The panel validates the value against its own catalog before calling; the server stores it verbatim.

type SSEHandler

type SSEHandler struct {
	Pool       *pgxpool.Pool
	AdminToken string
}

SSEHandler streams session-changed events to authorized callers (panel). Callers prove authority with `Authorization: Admin <token>` — same scheme used by Connect's owner-mode interceptor.

func NewSSEHandler

func NewSSEHandler(pool *pgxpool.Pool, adminToken string) *SSEHandler

func (*SSEHandler) ServeHTTP

func (h *SSEHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SessionsHandler

SessionsHandler implements the SessionsService Connect interface.

func NewSessionsHandler

func NewSessionsHandler(pool *pgxpool.Pool, obj *storage.ObjectStore) *SessionsHandler

func (*SessionsHandler) Get

func (*SessionsHandler) GetRaw

GetRaw streams a byte-range window of the session's raw transcript from S3.

func (*SessionsHandler) List

func (*SessionsHandler) ListChildren

ListChildren returns every session whose parent_session_id matches the request id, ordered started_at ASC so the panel can render them in spawn order.

func (*SessionsHandler) Push

Jump to

Keyboard shortcuts

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