tablehttp

package
v1.125.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package tablehttp serves the register / unregister actions that make an uploaded file readable as a query-engine table (#1327).

One handler serves both kinds. A managed resource and a portal asset reach the registrar through different records -- a resource is a person's upload, an asset is what the platform wrote for them -- but the action, the request body, and the response are the same, so the parts that differ are a Subject resolver per kind and nothing else.

It sits beside the resource and portal handlers rather than inside them: the routes it registers are more specific than the prefix mounts those handlers occupy, so ServeMux gives them precedence, and neither public package gains a dependency on the registrar.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionChoice

type ConnectionChoice struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Catalog     string `json:"catalog"`
	Schema      string `json:"schema"`
}

ConnectionChoice is one connection a person can register onto.

type ConnectionEnumerator

type ConnectionEnumerator func(ctx context.Context, user *portal.User) []ConnectionChoice

ConnectionEnumerator lists the connections this caller may register onto: granted to their persona and carrying a scratch target. It is the picker's only source, so a connection the form offers is one the registrar accepts.

type Deps

type Deps struct {
	Registrar *tableregister.Registrar
	// Resources and Assets resolve the two kinds. Either may be nil, which
	// leaves that kind's routes unregistered rather than answering an error.
	Resources Subject
	Assets    Subject
	// Connections fills the picker. Nil serves an empty list, which a form
	// renders as "no connection here can hold a table".
	Connections ConnectionEnumerator
	// Caller builds the registrar's view of the authenticated user: their
	// persona and whether they are an administrator.
	Caller func(*portal.User) tableregister.Caller
}

Deps is what the handler needs.

type Handler

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

Handler serves the table routes.

func New

func New(deps Deps) *Handler

New builds a Handler, or nil when nothing can be registered -- no registrar, or neither kind resolvable. Nil is meaningful: Routes on a nil handler registers nothing, so a deployment with no Trino toolkit or no database never advertises an action that would always refuse.

func (*Handler) Routes

func (h *Handler) Routes(mux *http.ServeMux, wrap func(http.Handler) http.Handler)

Routes registers the table routes on a mux, each wrapped by the portal authentication middleware the surrounding surface uses.

type Subject

type Subject = tableregister.Subject

Subject resolves the record a route's {id} names into what the registrar needs, and decides whether this caller may act on it. Returning ok=false means the caller may not act on the record at all, which is answered as a not-found so the surface never reveals a record the caller could not reach.

It is the registrar's own resolver type rather than one of this package's, so the rule for who may register a file is written once and serves the tool surface as well as these routes.

Jump to

Keyboard shortcuts

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