{"modulePath":"github.com/txn2/mcp-data-platform","version":"v1.172.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tablehttp\n\nPackage tablehttp serves the register / unregister actions that make an uploaded file readable as a query-engine table (#1327).\n\nOne 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.\n\nIt 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.\n\n## Types\n\n```go\ntype ConnectionChoice struct {\n\tName        string `json:\"name\"`\n\tDescription string `json:\"description,omitempty\"`\n\tCatalog     string `json:\"catalog\"`\n\tSchema      string `json:\"schema\"`\n}\n```\nConnectionChoice is one connection a person can register onto.\n\n```go\ntype ConnectionEnumerator func(ctx context.Context, user *portal.User) []ConnectionChoice\n```\nConnectionEnumerator 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.\n\n```go\ntype Deps struct {\n\tRegistrar *tableregister.Registrar\n\t// Resources and Assets resolve the two kinds. Either may be nil, which\n\t// leaves that kind's routes unregistered rather than answering an error.\n\tResources Subject\n\tAssets    Subject\n\t// Connections fills the picker. Nil serves an empty list, which a form\n\t// renders as \"no connection here can hold a table\".\n\tConnections ConnectionEnumerator\n\t// Visible reports the connections a caller may SEE registrations on, which\n\t// is a wider set than Connections: the picker narrows to connections that\n\t// can hold a NEW table, and a listing has to keep showing the tables\n\t// already on one that no longer can.\n\tVisible Visibility\n\t// Sources resolves the records a cross-source listing names. Nil leaves\n\t// every row without a source name and without the unregister action,\n\t// which is the listing a deployment that cannot resolve its sources can\n\t// honestly serve.\n\tSources tableregister.Sources\n\t// Caller builds the registrar's view of the authenticated user: their\n\t// persona and whether they are an administrator.\n\tCaller func(*portal.User) tableregister.Caller\n}\n```\nDeps is what the handler needs.\n\n```go\ntype Handler struct {\n\t// contains filtered or unexported fields\n}\n```\nHandler serves the table routes.\n\n```go\nfunc New(deps Deps) *Handler\n```\nNew 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.\n\n```go\nfunc (h *Handler) Routes(mux *http.ServeMux, wrap func(http.Handler) http.Handler)\n```\nRoutes registers the table routes on a mux, each wrapped by the portal authentication middleware the surrounding surface uses.\n\n```go\ntype Subject = tableregister.Subject\n```\nSubject 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.\n\nIt 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.\n\n```go\ntype Visibility func(ctx context.Context, caller tableregister.Caller) (connections []string, all bool)\n```\nVisibility reports the connections a caller may see registrations on. all lifts the boundary entirely, which is what an administrator gets.\n\nA nil Visibility on the handler shows an administrator everything and everyone else nothing, which is the fail-closed reading of a deployment that cannot enumerate its connections.\n\n","path":"github.com/txn2/mcp-data-platform/internal/httpserver/tablehttp","name":"tablehttp","synopsis":"Package tablehttp serves the register / unregister actions that make an uploaded file readable as a query-engine table (#1327).","isRedistributable":true}
