handler

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 47 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleChangesList added in v0.4.0

func HandleChangesList(cfg *config.Config) http.HandlerFunc

HandleChangesList: GET /admin/tenants/{tenantID}/changes?since=0&table=&limit=100 reads a tenant's realtime change log (readable columns, oldest first) and the last seq; limit=0 returns only the seq, to follow from now.

func HandleCreate

func HandleCreate(pool *tenant.PoolManager) http.HandlerFunc

func HandleDelete

func HandleDelete(pool *tenant.PoolManager) http.HandlerFunc

func HandleDeploy added in v0.2.0

func HandleDeploy(cfg *config.Config, store *tenant.CachedStore) http.HandlerFunc

HandleDeploy: PUT /admin/tenants/{tenantID} — validate a supacraft.json, migrate the tenant's database (additive) and write its config. Nothing is changed when validation fails, the tenant id belongs to another project, or secrets are missing.

func HandleFileDelete

func HandleFileDelete(pool *tenant.PoolManager, serverCfg *config.Config) http.HandlerFunc

func HandleFileDownload

func HandleFileDownload(pool *tenant.PoolManager, serverCfg *config.Config) http.HandlerFunc

func HandleFileUpload

func HandleFileUpload(pool *tenant.PoolManager, serverCfg *config.Config) http.HandlerFunc

func HandleForgotPassword added in v0.3.0

func HandleForgotPassword(pool *tenant.PoolManager) http.HandlerFunc

HandleForgotPassword: POST /auth/forgot-password {"email"}

func HandleFunction

func HandleFunction(pool *tenant.PoolManager) http.HandlerFunc

HandleFunction handles requests to pipeline function routes under /fn/*.

func HandleJobEnqueue added in v0.4.0

func HandleJobEnqueue(cfg *config.Config) http.HandlerFunc

HandleJobEnqueue: POST /admin/tenants/{tenantID}/jobs queues a PRIVATE function to run as a job.

func HandleJobRetry added in v0.4.0

func HandleJobRetry(cfg *config.Config) http.HandlerFunc

HandleJobRetry: POST /admin/tenants/{tenantID}/jobs/{jobID}/retry queues a failed job again.

func HandleJobsList added in v0.4.0

func HandleJobsList(cfg *config.Config) http.HandlerFunc

HandleJobsList: GET /admin/tenants/{tenantID}/jobs?status=failed&limit=50 lists a tenant's background jobs, newest first. Last errors can quote anything a step touched, so secret values are masked.

func HandleLogin

func HandleLogin(pool *tenant.PoolManager) http.HandlerFunc

func HandleOAuthCallback added in v0.4.0

func HandleOAuthCallback(pool *tenant.PoolManager) http.HandlerFunc

HandleOAuthCallback: GET /auth/oauth/{provider}/callback?code&state — the provider sends the browser back here. The user is found or created and the browser goes on to redirect_to?code=<one-time login code> (or ?error=<reason>); the app exchanges the code at /auth/oauth/exchange.

func HandleOAuthExchange added in v0.4.0

func HandleOAuthExchange(pool *tenant.PoolManager) http.HandlerFunc

HandleOAuthExchange: POST /auth/oauth/exchange {"code", "code_verifier"} turns the login code from the callback redirect into the tokens /auth/login returns; code_verifier must match the start's challenge.

func HandleOAuthStart added in v0.4.0

func HandleOAuthStart(pool *tenant.PoolManager) http.HandlerFunc

HandleOAuthStart: GET /auth/oauth/{provider}/start?redirect_to=<app url> &code_challenge=<S256 of an app-held verifier> (&tenant=<id> on a central server) sends the browser to the provider.

func HandleOpenAPI added in v0.4.0

func HandleOpenAPI(serverCfg *config.Config) http.HandlerFunc

HandleOpenAPI: GET /meta/openapi.json describes the tenant's endpoints: what each accepts and returns, nothing else of the schema. Projects turn it off with api_settings.openapi: false.

func HandleQuery

func HandleQuery(pool *tenant.PoolManager) http.HandlerFunc

func HandleRealtime added in v0.4.0

func HandleRealtime(pool *tenant.PoolManager, hub *realtime.Hub, trustProxy bool) http.HandlerFunc

HandleRealtime: GET /realtime upgrades to a WebSocket that streams the changes of api_settings.realtime tables (see the reference for the protocol).

func HandleRefresh

func HandleRefresh(pool *tenant.PoolManager) http.HandlerFunc

func HandleRegister

func HandleRegister(pool *tenant.PoolManager) http.HandlerFunc

func HandleResendVerification added in v0.3.0

func HandleResendVerification(pool *tenant.PoolManager) http.HandlerFunc

HandleResendVerification: POST /auth/resend-verification {"email"}

func HandleResetPassword added in v0.3.0

func HandleResetPassword(pool *tenant.PoolManager) http.HandlerFunc

HandleResetPassword: POST /auth/reset-password {"token", "password"}

func HandleSecretSet added in v0.2.0

func HandleSecretSet(cfg *config.Config, store *tenant.CachedStore) http.HandlerFunc

HandleSecretSet: PUT /admin/tenants/{tenantID}/secrets/{name} {"value": "..."}

func HandleSecretUnset added in v0.2.0

func HandleSecretUnset(cfg *config.Config, store *tenant.CachedStore) http.HandlerFunc

HandleSecretUnset: DELETE /admin/tenants/{tenantID}/secrets/{name}

func HandleSecretsList added in v0.2.0

func HandleSecretsList(cfg *config.Config) http.HandlerFunc

HandleSecretsList: GET /admin/tenants/{tenantID}/secrets

func HandleStudioQuery

func HandleStudioQuery(store *tenant.CachedStore, pool *tenant.PoolManager) http.HandlerFunc

HandleStudioQuery runs a read-only, schema-validated SELECT against a tenant.

func HandleStudioSchema

func HandleStudioSchema(store *tenant.CachedStore) http.HandlerFunc

HandleStudioSchema returns a tenant's schema (readable columns only).

func HandleStudioTenants

func HandleStudioTenants(store *tenant.CachedStore) http.HandlerFunc

HandleStudioTenants lists every tenant with its db_name and table count.

func HandleTenantErrors added in v0.3.0

func HandleTenantErrors(cfg *config.Config, errLog *errorlog.ErrorLog) http.HandlerFunc

HandleTenantErrors: GET /admin/tenants/{tenantID}/errors?limit=50&offset=0 returns the tenant's recent API errors for the operator. Messages can quote anything a step touched, so the tenant's secret values are masked.

func HandleTenantRemove added in v0.3.0

func HandleTenantRemove(cfg *config.Config, store *tenant.CachedStore, pool *tenant.PoolManager) http.HandlerFunc

HandleTenantRemove: DELETE /admin/tenants/{tenantID}[?purge=true] stops serving a tenant; with purge it also deletes its database, uploads and secrets (see tenant.RemoveTenant).

func HandleTenantSetDisabled added in v0.3.0

func HandleTenantSetDisabled(cfg *config.Config, store *tenant.CachedStore, disabled bool) http.HandlerFunc

HandleTenantSetDisabled: POST /admin/tenants/{tenantID}/disable and /enable

func HandleTenantsList added in v0.3.0

func HandleTenantsList(cfg *config.Config) http.HandlerFunc

HandleTenantsList: GET /admin/tenants

func HandleUpdate

func HandleUpdate(pool *tenant.PoolManager) http.HandlerFunc

func HandleUserSetRole added in v0.4.0

func HandleUserSetRole(cfg *config.Config) http.HandlerFunc

HandleUserSetRole: POST /admin/tenants/{tenantID}/users/role gives a user one of the tenant's roles.

func HandleUsersList added in v0.4.0

func HandleUsersList(cfg *config.Config) http.HandlerFunc

HandleUsersList: GET /admin/tenants/{tenantID}/users?limit=50&offset=0 lists a tenant's users with their roles (never password hashes).

func HandleVerifyEmail added in v0.3.0

func HandleVerifyEmail(pool *tenant.PoolManager) http.HandlerFunc

HandleVerifyEmail: POST /auth/verify-email {"token"}

func MaskJobs added in v0.4.0

func MaskJobs(list []tenant.Job, vals map[string]string)

MaskJobs masks secret values in job errors and args, nested ones too.

func MaskSecrets added in v0.3.0

func MaskSecrets(s string, vals map[string]string) string

MaskSecrets replaces every secret value found in s with "[secret NAME]", longest values first so one value inside another is still masked whole. Values under 4 bytes are left alone; masking them would garble the text without hiding anything guessable.

func MaskValue added in v0.4.0

func MaskValue(v any, vals map[string]string) any

MaskValue masks secret values in every string of a JSON value.

func NewRouter

func NewRouter(store *tenant.CachedStore, pool *tenant.PoolManager, errLog *errorlog.ErrorLog, serverCfg *config.Config, hub *realtime.Hub) http.Handler

NewRouter builds the API. hub streams table changes on /realtime; nil gives the router its own.

Types

type AuthRequest

type AuthRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type ChangesResponse added in v0.4.0

type ChangesResponse struct {
	Data    []tenant.Change `json:"data"`
	LastSeq int64           `json:"last_seq"`
}

ChangesResponse is the answer of GET /admin/tenants/{id}/changes.

type CreateRequest

type CreateRequest struct {
	TableID string         `json:"table_id"`
	Data    map[string]any `json:"data"`
}

type DeleteRequest

type DeleteRequest struct {
	TableID string         `json:"table_id"`
	Where   map[string]any `json:"where"`
}

type DeployRequest added in v0.2.0

type DeployRequest struct {
	Project map[string]any `json:"project"`
	Replace bool           `json:"replace,omitempty"`
	DryRun  bool           `json:"dry_run,omitempty"`
	// AllowMissingSecrets deploys even when "${NAME}" references have no
	// secret yet; they resolve to "" until set.
	AllowMissingSecrets bool `json:"allow_missing_secrets,omitempty"`
}

DeployRequest is the body of PUT /admin/tenants/{tenantID}.

type DeployResponse added in v0.2.0

type DeployResponse struct {
	Tenant         string          `json:"tenant"`
	DryRun         bool            `json:"dry_run"`
	Created        bool            `json:"database_created"`
	Migrations     []string        `json:"migrations"`
	MissingSecrets []string        `json:"missing_secrets"`
	Warnings       []project.Issue `json:"warnings"`
}

DeployResponse reports what a deploy changed (or would change).

type EnqueueRequest added in v0.4.0

type EnqueueRequest struct {
	Function string         `json:"function"`
	Args     map[string]any `json:"args,omitempty"`
	Delay    int            `json:"delay,omitempty"` // seconds
}

EnqueueRequest is the body of POST /admin/tenants/{tenantID}/jobs.

type QueryRequest

type QueryRequest struct {
	TableID string                 `json:"table_id"`
	Select  []string               `json:"select"`
	Include []query.IncludeRequest `json:"include"`
	Where   map[string]any         `json:"where"`
	OrderBy map[string]string      `json:"order_by"`
	Limit   int                    `json:"limit"`
	Offset  int                    `json:"offset"`
	Cursor  string                 `json:"cursor"`
}

type RefreshRequest

type RefreshRequest struct {
	RefreshToken string `json:"refresh_token"`
}

type SecretsStatus added in v0.2.0

type SecretsStatus struct {
	Tenant     string   `json:"tenant"`
	Deployed   bool     `json:"deployed"`
	Set        []string `json:"set"`
	Referenced []string `json:"referenced"`
	Missing    []string `json:"missing"`
}

SecretsStatus is the response of GET /admin/tenants/{id}/secrets. It carries names only; secret values are never returned.

func SecretsStatusFor added in v0.2.0

func SecretsStatusFor(dataDir, id string) (*SecretsStatus, error)

SecretsStatusFor compares a tenant's stored secret names with the names its deployed config references.

type SetRoleRequest added in v0.4.0

type SetRoleRequest struct {
	Email string `json:"email"`
	Role  string `json:"role"`
}

SetRoleRequest is the body of POST /admin/tenants/{tenantID}/users/role.

type UpdateRequest

type UpdateRequest struct {
	TableID string         `json:"table_id"`
	Where   map[string]any `json:"where"`
	Data    map[string]any `json:"data"`
}

Jump to

Keyboard shortcuts

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