{"modulePath":"github.com/txn2/mcp-data-platform","version":"v1.171.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package apishttp\n\nPackage apishttp serves /api/v1/apis: the read surface that answers, for one caller, which api-kind connections they reach and what operations each one exposes.\n\nIt is the caller-scoped half of the operation browser (#1478). The operator's half lives on the admin catalog routes and describes what has been LOADED; this one describes what a persona may CALL, which is a different set: a connection outside the persona's rules is absent, and so is an operation an APIRoutes deny rule refuses. Both come from the toolkit's own browse methods, which apply the same route policy api\\_discover applies, so this surface and that tool cannot disagree about what a caller reaches.\n\nIts path is /api/v1/apis rather than something under /api/v1/portal because its second reader is not the portal: a client driving the gateway over plain HTTP needs the same inventory before it can compose an invoke body. It is mounted with the portal's routes all the same, behind the portal's own authenticator, which accepts a session cookie and a bearer token or API key alike — so one mount serves the page and that client both.\n\nNothing here executes an upstream call. The invoke route is the one that does.\n\n## Types\n\n```go\ntype Caller struct {\n\tUserID string\n\tEmail  string\n\t// Roles are what the route policy resolves an operation's verdict from.\n\tRoles []string\n\t// Persona is the caller's resolved persona, whose connection rules decide\n\t// which connections they reach. An unresolved persona reaches nothing.\n\tPersona string\n\t// IsAdmin lifts the persona boundary, which is what an administrator has\n\t// everywhere else in the product.\n\tIsAdmin bool\n}\n```\nCaller is the authenticated reader a listing is narrowed to.\n\n```go\ntype Connection struct {\n\tName        string\n\tKind        string\n\tDescription string\n}\n```\nConnection is one connection a caller reaches, as the enumerator reports it.\n\n```go\ntype Deps struct {\n\t// Caller resolves the authenticated reader. Nil leaves the routes\n\t// unmounted: a surface that cannot tell who is asking cannot narrow\n\t// anything to them.\n\tCaller func(r *http.Request) *Caller\n\t// Connections enumerates what a caller reaches. It is the composition\n\t// root's, because resolving it means walking the live toolkit registry\n\t// through the persona boundary and this package holds neither. It takes\n\t// the whole Caller rather than a narrowing of it, so the answer and the\n\t// identity it was drawn for cannot drift apart.\n\t//\n\t// Nil leaves the routes unmounted, for the same reason connreach yields a\n\t// nil Lister: a deployment that cannot enumerate its connections should\n\t// serve no set rather than an empty one a page renders as \"you reach\n\t// nothing\".\n\tConnections func(ctx context.Context, caller *Caller) []Connection\n\t// Locate finds the api-gateway toolkit serving one connection, or nil when\n\t// no live toolkit does. Nil leaves the routes unmounted.\n\tLocate func(connection string) OperationBrowser\n\t// Elevate puts the caller's identity on the context the toolkit reads, so\n\t// the route policy resolves the same roles it would resolve for that\n\t// caller's tool call. Nil means no elevation, which the policy reads as an\n\t// anonymous caller.\n\tElevate func(ctx context.Context, c *Caller) context.Context\n}\n```\nDeps wires the surface to the caller resolution, the enumeration, and the toolkits that answer for a connection.\n\n```go\ntype Handler struct {\n\t// contains filtered or unexported fields\n}\n```\nHandler serves the routes.\n\n```go\nfunc New(deps Deps) *Handler\n```\nNew builds a Handler.\n\n```go\nfunc (h *Handler) Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler)\n```\nRegister mounts the routes, wrapped in the supplied authentication middleware. Returns without mounting anything when the deployment cannot answer who is asking or what they reach.\n\n```go\ntype OperationBrowser interface {\n\tBrowseConnection(ctx context.Context, name string) (*apigatewaykit.BrowseConnection, error)\n\tBrowseOperations(ctx context.Context, connection string) ([]apigatewaykit.OperationSummary, error)\n\tBrowseOperation(ctx context.Context, connection, operationID, spec string) (*apigatewaykit.EndpointSchemaOutput, error)\n}\n```\nOperationBrowser is the per-connection read path, implemented by \\*apigateway.Toolkit. Declared as an interface so this package can be tested without materializing a toolkit and its HTTP clients.\n\n","path":"github.com/txn2/mcp-data-platform/internal/httpserver/apishttp","name":"apishttp","synopsis":"Package apishttp serves /api/v1/apis: the read surface that answers, for one caller, which api-kind connections they reach and what operations each one exposes.","isRedistributable":true}
