Documentation
¶
Overview ¶
Package handler holds the HTTP handlers for the Contexo git-backed server.
Index ¶
- type EvolutionEntry
- type Handler
- func (h *Handler) Activity(c *gin.Context)
- func (h *Handler) CreatePAT(c *gin.Context)
- func (h *Handler) CreateRepo(c *gin.Context)
- func (h *Handler) CreateRepoLegacy(c *gin.Context)
- func (h *Handler) DeleteInviteKey(c *gin.Context)
- func (h *Handler) DeletePAT(c *gin.Context)
- func (h *Handler) Diff(c *gin.Context)
- func (h *Handler) Distill(c *gin.Context)
- func (h *Handler) Evolution(c *gin.Context)
- func (h *Handler) GoogleAuth(c *gin.Context)
- func (h *Handler) History(c *gin.Context)
- func (h *Handler) JoinRepo(c *gin.Context)
- func (h *Handler) ListInviteKeys(c *gin.Context)
- func (h *Handler) ListMembers(c *gin.Context)
- func (h *Handler) ListPATs(c *gin.Context)
- func (h *Handler) ListPages(c *gin.Context)
- func (h *Handler) ListRepos(c *gin.Context)
- func (h *Handler) Me(c *gin.Context)
- func (h *Handler) MintInviteKey(c *gin.Context)
- func (h *Handler) Pull(c *gin.Context)
- func (h *Handler) Push(c *gin.Context)
- func (h *Handler) ReadPage(c *gin.Context)
- func (h *Handler) RemoveMember(c *gin.Context)
- func (h *Handler) SetQuota(p quota.Policy)
- func (h *Handler) Timeline(c *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EvolutionEntry ¶
type EvolutionEntry struct {
Commit gitstore.CommitMeta `json:"commit"`
Diff diff.SectionDiff `json:"diff"`
}
EvolutionEntry pairs one commit with its diff against the prior version of the same path. For the very first commit (no prior version) the diff compares against an empty document, so every section surfaces as added.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler holds dependencies for every HTTP route.
func New ¶
func New(store *gitstore.Store, users *userstore.Store, signer *auth.SessionSigner, google auth.Verifier) *Handler
New constructs a Handler. users/signer/google may be nil during tests of the gitstore-only paths. The quota policy defaults to Unlimited (no caps); the hosted build overrides it via SetQuota.
func (*Handler) Activity ¶
Activity handles GET /v1/repos/:id/activity?limit=N&offset=M. Any member may view the repo's push/pull feed (newest first); total drives pagination.
func (*Handler) CreateRepo ¶
CreateRepo handles POST /v1/repos. The caller becomes the owner.
func (*Handler) CreateRepoLegacy ¶
CreateRepoLegacy handles the deprecated POST /v1/repos/:id used by the existing CLI's repo-init flow. Kept for back-compat with legacy auth; real users should use POST /v1/repos.
func (*Handler) DeleteInviteKey ¶
DeleteInviteKey handles DELETE /v1/repos/:id/invite-keys/:keyId.
func (*Handler) Diff ¶
Diff handles GET /v1/repos/:id/diff/*path?from=&to=.
Defaults when query params are omitted:
- to absent → HEAD-for-this-path (most recent commit touching the path)
- from absent → parent commit of `to` for this path
- both absent → most recent change for the path (parent..head)
Returns 400 if a sha doesn't resolve or if `from` defaults are impossible (e.g. the page only has one commit, so there is no parent). Returns 404 if the path doesn't exist at either side.
func (*Handler) Distill ¶
Distill handles POST /v1/repos/:id/sync/distill.
This is a Phase 2 stub. The real implementation (server-side reasoning- trail distillation as a fallback for clients that cannot run the agent-as-distiller flow) is Phase 4 in the rollout plan. Until then we return 501 so the CLI's --fallback-server flag has something to talk to and the contract is visible to the dashboard team.
func (*Handler) Evolution ¶
Evolution handles GET /v1/repos/:id/evolution/*path?limit=N.
Returns up to N most recent commits touching `*path`, each paired with the section-aware diff against its immediate prior commit for the same path. Designed for agents and humans who want the full trajectory of a page in a single round-trip instead of one history call + N diff calls.
func (*Handler) GoogleAuth ¶
GoogleAuth handles POST /v1/auth/google. Verifies the Google ID token, upserts the user, and returns a session JWT. On the very first sign-in (when the users table is empty), the user inherits ownership of every existing un-owned repo on the server.
func (*Handler) ListInviteKeys ¶
ListInviteKeys handles GET /v1/repos/:id/invite-keys.
func (*Handler) ListMembers ¶
ListMembers handles GET /v1/repos/:id/members. Any member of the repo may list its members.
func (*Handler) ListRepos ¶
ListRepos handles GET /v1/repos. Returns every repo for legacy auth, or just the user's memberships for real users.
func (*Handler) MintInviteKey ¶
MintInviteKey handles POST /v1/repos/:id/invite-keys.
func (*Handler) Push ¶
Push handles POST /v1/repos/:id/sync/push. For real users, the first push to a new repo auto-creates and assigns ownership.
func (*Handler) RemoveMember ¶
RemoveMember handles DELETE /v1/repos/:id/members/:userId. Only an owner may remove a member, and the last owner cannot be removed.