handlers

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateScenario

func CreateScenario(s store.Store) http.HandlerFunc

func CreateSession

func CreateSession(s store.Store) http.HandlerFunc

func DeleteScenario

func DeleteScenario(s store.Store) http.HandlerFunc

func DeleteSession

func DeleteSession(s store.Store) http.HandlerFunc

func Feedback added in v1.2.0

func Feedback(s store.Store) http.HandlerFunc

Feedback accepts submissions from the in-app widget. Public endpoint — anonymous docs visitors can submit too. Writes to feedback_submissions in Postgres; identity fields (workspace_id, user_id) populate when a session cookie is present, otherwise nil.

Size-cap each free-text field so a noisy caller can't balloon the DB.

func GetLog

func GetLog(s store.Store) http.HandlerFunc

func GetScenario

func GetScenario(s store.Store) http.HandlerFunc

func GetWebhook

func GetWebhook(s store.Store) http.HandlerFunc

GetWebhook returns one webhook_log by its id (not by request_log_id).

func GetWebhookStatus

func GetWebhookStatus(s store.Store) http.HandlerFunc

func GetWorkspace

func GetWorkspace(s store.Store) http.HandlerFunc

func Healthz added in v1.2.0

func Healthz() http.HandlerFunc

Healthz returns a minimal liveness probe suitable for uptime pingers.

Keep this handler side-effect-free: no DB work, no store calls, no logs on the happy path. It runs on every 5-minute uptime ping and we don't want the logs table polluted with thousands of probe entries.

Returns 200 OK with a tiny JSON body so observability tools that parse the response can confirm they spoke to the Go binary (not an upstream proxy or CDN that happens to return 200 on anything).

func ListGateways

func ListGateways(reg *adapters.Registry) http.HandlerFunc

ListGateways returns the set of canonical gateway names known to the server. The dashboard uses this to render per-gateway webhook configuration dynamically so the UI stays in sync with whatever adapters are registered.

func ListLogs

func ListLogs(s store.Store) http.HandlerFunc

func ListScenarios

func ListScenarios(s store.Store) http.HandlerFunc

func ListWebhooks

func ListWebhooks(s store.Store) http.HandlerFunc

ListWebhooks returns all webhook dispatches for the caller's workspace, newest first. Each entry includes target URL, delivery status, attempts, attempt_logs, and the payload sent.

func Login

func Login(s store.Store, jwtSecret, mode string) http.HandlerFunc

func Logout

func Logout(mode string) http.HandlerFunc

func Me

func NewMock

func NewMockWithMode

func NewMockWithMode(eng *engine.Engine, reg *adapters.Registry, s store.Store, d *webhook.Dispatcher, mode string) http.Handler

func Signup

func Signup(s store.Store, jwtSecret, mode string) http.HandlerFunc

func TestWebhook

func TestWebhook(d *webhook.Dispatcher) http.HandlerFunc

func UpdateScenario

func UpdateScenario(s store.Store) http.HandlerFunc

func UpdateWorkspace

func UpdateWorkspace(s store.Store) http.HandlerFunc

UpdateWorkspace lets the authenticated caller edit mutable workspace fields. Currently only WebhookURLs (a gateway → URL map) is editable.

func WorkspaceFromRequest

func WorkspaceFromRequest(r *http.Request, s store.Store) (*store.Workspace, error)

WorkspaceFromRequest resolves the workspace the current request should act on. Priority:

  1. Authorization: Bearer <api_key> → lookup by api_key
  2. Session cookie (Session middleware injects workspace_id into ctx) → by id
  3. Local fallback: the "local" workspace

Exposed so other handlers can scope queries by caller's workspace.

func WorkspaceIDFromRequest

func WorkspaceIDFromRequest(r *http.Request, s store.Store) string

WorkspaceIDFromRequest is a thin convenience wrapper returning just the ID. Falls back to LocalWorkspaceID if lookup fails.

func WorkspaceUsage added in v1.3.0

func WorkspaceUsage(s store.Store) http.HandlerFunc

WorkspaceUsage returns the current workspace's 24h request count and its configured daily cap. Frontend polls this to render the quota pill. Cheap — one indexed COUNT on request_logs.

Response shape:

{ "used_today": 47, "cap": 200 }

`cap` is nil when the workspace is unlimited (standard signed-up case). Frontend hides the pill entirely in that case.

Types

type MockHandler

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

func (*MockHandler) ServeHTTP

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

Jump to

Keyboard shortcuts

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