Help us shape the future of Go! Take the 2026 Go Developer Survey

changesethttp

package
v1.152.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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.

func Register

func Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler, d Deps)

Register mounts the routes on mux, each behind wrap (the portal's authentication and access gate). Nothing is mounted without a handler.

Types

type Caller

type Caller struct {
	UserID string
	Email  string
	Roles  []string
}

Caller is the authenticated portal user.

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.

Jump to

Keyboard shortcuts

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