Documentation
¶
Index ¶
- func HandleChangesList(cfg *config.Config) http.HandlerFunc
- func HandleCreate(pool *tenant.PoolManager) http.HandlerFunc
- func HandleDelete(pool *tenant.PoolManager) http.HandlerFunc
- func HandleDeploy(cfg *config.Config, store *tenant.CachedStore) http.HandlerFunc
- func HandleFileDelete(pool *tenant.PoolManager, serverCfg *config.Config) http.HandlerFunc
- func HandleFileDownload(pool *tenant.PoolManager, serverCfg *config.Config) http.HandlerFunc
- func HandleFileUpload(pool *tenant.PoolManager, serverCfg *config.Config) http.HandlerFunc
- func HandleForgotPassword(pool *tenant.PoolManager) http.HandlerFunc
- func HandleFunction(pool *tenant.PoolManager) http.HandlerFunc
- func HandleJobEnqueue(cfg *config.Config) http.HandlerFunc
- func HandleJobRetry(cfg *config.Config) http.HandlerFunc
- func HandleJobsList(cfg *config.Config) http.HandlerFunc
- func HandleLogin(pool *tenant.PoolManager) http.HandlerFunc
- func HandleOAuthCallback(pool *tenant.PoolManager) http.HandlerFunc
- func HandleOAuthExchange(pool *tenant.PoolManager) http.HandlerFunc
- func HandleOAuthStart(pool *tenant.PoolManager) http.HandlerFunc
- func HandleOpenAPI(serverCfg *config.Config) http.HandlerFunc
- func HandleQuery(pool *tenant.PoolManager) http.HandlerFunc
- func HandleRealtime(pool *tenant.PoolManager, hub *realtime.Hub, trustProxy bool) http.HandlerFunc
- func HandleRefresh(pool *tenant.PoolManager) http.HandlerFunc
- func HandleRegister(pool *tenant.PoolManager) http.HandlerFunc
- func HandleResendVerification(pool *tenant.PoolManager) http.HandlerFunc
- func HandleResetPassword(pool *tenant.PoolManager) http.HandlerFunc
- func HandleSecretSet(cfg *config.Config, store *tenant.CachedStore) http.HandlerFunc
- func HandleSecretUnset(cfg *config.Config, store *tenant.CachedStore) http.HandlerFunc
- func HandleSecretsList(cfg *config.Config) http.HandlerFunc
- func HandleStudioQuery(store *tenant.CachedStore, pool *tenant.PoolManager) http.HandlerFunc
- func HandleStudioSchema(store *tenant.CachedStore) http.HandlerFunc
- func HandleStudioTenants(store *tenant.CachedStore) http.HandlerFunc
- func HandleTenantErrors(cfg *config.Config, errLog *errorlog.ErrorLog) http.HandlerFunc
- func HandleTenantRemove(cfg *config.Config, store *tenant.CachedStore, pool *tenant.PoolManager) http.HandlerFunc
- func HandleTenantSetDisabled(cfg *config.Config, store *tenant.CachedStore, disabled bool) http.HandlerFunc
- func HandleTenantsList(cfg *config.Config) http.HandlerFunc
- func HandleUpdate(pool *tenant.PoolManager) http.HandlerFunc
- func HandleUserSetRole(cfg *config.Config) http.HandlerFunc
- func HandleUsersList(cfg *config.Config) http.HandlerFunc
- func HandleVerifyEmail(pool *tenant.PoolManager) http.HandlerFunc
- func MaskJobs(list []tenant.Job, vals map[string]string)
- func MaskSecrets(s string, vals map[string]string) string
- func MaskValue(v any, vals map[string]string) any
- func NewRouter(store *tenant.CachedStore, pool *tenant.PoolManager, errLog *errorlog.ErrorLog, ...) http.Handler
- type AuthRequest
- type ChangesResponse
- type CreateRequest
- type DeleteRequest
- type DeployRequest
- type DeployResponse
- type EnqueueRequest
- type QueryRequest
- type RefreshRequest
- type SecretsStatus
- type SetRoleRequest
- type UpdateRequest
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
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
MaskJobs masks secret values in job errors and args, nested ones too.
func MaskSecrets ¶ added in v0.3.0
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.
Types ¶
type AuthRequest ¶
type ChangesResponse ¶ added in v0.4.0
ChangesResponse is the answer of GET /admin/tenants/{id}/changes.
type CreateRequest ¶
type DeleteRequest ¶
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
SetRoleRequest is the body of POST /admin/tenants/{tenantID}/users/role.