Documentation
¶
Overview ¶
Package changesethttp serves the knowledge changesets to the portal (#2337): the list, one changeset, and its rollback under /api/v1/portal/knowledge/changesets, for a caller who holds apply_knowledge.
The portal's Changesets tab is offered on that capability, not on the admin role, and the apply_knowledge tool already lists and rolls back changesets for whoever holds it. These routes give the tab the same audience: they run the admin API's own changeset handlers, so the two surfaces answer alike, with the portal caller named as the one who rolled a changeset back.
It lives beside pkg/portal, like the other portal route packages here, so the portal package stays within its size budget.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KnowledgeHandler ¶
func KnowledgeHandler(p *platform.Platform) *admin.KnowledgeHandler
KnowledgeHandler is the knowledge review and changeset handler, nil without an insight store: the admin API serves it, and Mount serves its changesets to the portal.
func Mount ¶
func Mount(mux *http.ServeMux, wrap func(http.Handler) http.Handler, kh *admin.KnowledgeHandler, resolver portal.PersonaResolver, isAdmin func([]string) bool)
Mount serves kh's changesets to the portal's callers, each behind wrap, admitting whoever holds apply_knowledge: the tool resolver names, or an administrator. A nil kh mounts nothing.
Types ¶
type Changesets ¶
type Changesets interface {
ListChangesets(w http.ResponseWriter, r *http.Request)
GetChangeset(w http.ResponseWriter, r *http.Request)
RollbackChangeset(w http.ResponseWriter, r *http.Request)
}
Changesets is the admin API's changeset handler (admin.KnowledgeHandler).
type Deps ¶
type Deps struct {
Changesets Changesets
// Caller resolves the request's portal user, nil when it carries none.
Caller func(*http.Request) *Caller
// CanApply reports whether the caller holds apply_knowledge
// (access.Checker.HasApplyKnowledge: the persona's tool, or admin).
CanApply func(*Caller) bool
}
Deps carries what the routes need.