Documentation
¶
Overview ¶
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.
It 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_list_endpoints applies, so this surface and that tool cannot disagree about what a caller reaches.
Its 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.
Nothing here executes an upstream call. The invoke route is the one that does.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Caller ¶
type Caller struct {
UserID string
Email string
// Roles are what the route policy resolves an operation's verdict from.
Roles []string
// Persona is the caller's resolved persona, whose connection rules decide
// which connections they reach. An unresolved persona reaches nothing.
Persona string
// IsAdmin lifts the persona boundary, which is what an administrator has
// everywhere else in the product.
IsAdmin bool
}
Caller is the authenticated reader a listing is narrowed to.
type Connection ¶
Connection is one connection a caller reaches, as the enumerator reports it.
type Deps ¶
type Deps struct {
// Caller resolves the authenticated reader. Nil leaves the routes
// unmounted: a surface that cannot tell who is asking cannot narrow
// anything to them.
Caller func(r *http.Request) *Caller
// Connections enumerates what a caller reaches. It is the composition
// root's, because resolving it means walking the live toolkit registry
// through the persona boundary and this package holds neither. It takes
// the whole Caller rather than a narrowing of it, so the answer and the
// identity it was drawn for cannot drift apart.
//
// Nil leaves the routes unmounted, for the same reason connreach yields a
// nil Lister: a deployment that cannot enumerate its connections should
// serve no set rather than an empty one a page renders as "you reach
// nothing".
Connections func(ctx context.Context, caller *Caller) []Connection
// Locate finds the api-gateway toolkit serving one connection, or nil when
// no live toolkit does. Nil leaves the routes unmounted.
Locate func(connection string) OperationBrowser
// Elevate puts the caller's identity on the context the toolkit reads, so
// the route policy resolves the same roles it would resolve for that
// caller's tool call. Nil means no elevation, which the policy reads as an
// anonymous caller.
Elevate func(ctx context.Context, c *Caller) context.Context
}
Deps wires the surface to the caller resolution, the enumeration, and the toolkits that answer for a connection.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the routes.
type OperationBrowser ¶
type OperationBrowser interface {
BrowseConnection(ctx context.Context, name string) (*apigatewaykit.BrowseConnection, error)
BrowseOperations(ctx context.Context, connection string) ([]apigatewaykit.OperationSummary, error)
BrowseOperation(ctx context.Context, connection, operationID, spec string) (*apigatewaykit.EndpointSchemaOutput, error)
}
OperationBrowser 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.