handler

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package handler holds the HTTP handlers for the Contexo git-backed server.

Index

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

func (h *Handler) Activity(c *gin.Context)

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) CreatePAT

func (h *Handler) CreatePAT(c *gin.Context)

CreatePAT handles POST /v1/pats.

func (*Handler) CreateRepo

func (h *Handler) CreateRepo(c *gin.Context)

CreateRepo handles POST /v1/repos. The caller becomes the owner.

func (*Handler) CreateRepoLegacy

func (h *Handler) CreateRepoLegacy(c *gin.Context)

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

func (h *Handler) DeleteInviteKey(c *gin.Context)

DeleteInviteKey handles DELETE /v1/repos/:id/invite-keys/:keyId.

func (*Handler) DeletePAT

func (h *Handler) DeletePAT(c *gin.Context)

DeletePAT handles DELETE /v1/pats/:id.

func (*Handler) Diff

func (h *Handler) Diff(c *gin.Context)

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

func (h *Handler) Distill(c *gin.Context)

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

func (h *Handler) Evolution(c *gin.Context)

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

func (h *Handler) GoogleAuth(c *gin.Context)

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) History

func (h *Handler) History(c *gin.Context)

History handles GET /v1/repos/:id/history/*path?limit=N.

func (*Handler) JoinRepo

func (h *Handler) JoinRepo(c *gin.Context)

JoinRepo handles POST /v1/repos/join.

func (*Handler) ListInviteKeys

func (h *Handler) ListInviteKeys(c *gin.Context)

ListInviteKeys handles GET /v1/repos/:id/invite-keys.

func (*Handler) ListMembers

func (h *Handler) ListMembers(c *gin.Context)

ListMembers handles GET /v1/repos/:id/members. Any member of the repo may list its members.

func (*Handler) ListPATs

func (h *Handler) ListPATs(c *gin.Context)

ListPATs handles GET /v1/pats.

func (*Handler) ListPages

func (h *Handler) ListPages(c *gin.Context)

ListPages handles GET /v1/repos/:id/pages.

func (*Handler) ListRepos

func (h *Handler) ListRepos(c *gin.Context)

ListRepos handles GET /v1/repos. Returns every repo for legacy auth, or just the user's memberships for real users.

func (*Handler) Me

func (h *Handler) Me(c *gin.Context)

Me handles GET /v1/me. Returns the current user (rejecting legacy auth).

func (*Handler) MintInviteKey

func (h *Handler) MintInviteKey(c *gin.Context)

MintInviteKey handles POST /v1/repos/:id/invite-keys.

func (*Handler) Pull

func (h *Handler) Pull(c *gin.Context)

Pull handles GET /v1/repos/:id/sync/pull?since=<sha>.

func (*Handler) Push

func (h *Handler) Push(c *gin.Context)

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) ReadPage

func (h *Handler) ReadPage(c *gin.Context)

ReadPage handles GET /v1/repos/:id/pages/*path.

func (*Handler) RemoveMember

func (h *Handler) RemoveMember(c *gin.Context)

RemoveMember handles DELETE /v1/repos/:id/members/:userId. Only an owner may remove a member, and the last owner cannot be removed.

func (*Handler) SetQuota added in v0.5.0

func (h *Handler) SetQuota(p quota.Policy)

SetQuota installs the hosted usage-limit policy. The OSS/self-host server never calls this, so its handler keeps the Unlimited default — caps are a hosted-only concern. app.Run wires this from a WithQuota option.

func (*Handler) Timeline

func (h *Handler) Timeline(c *gin.Context)

Timeline handles GET /v1/repos/:id/timeline?limit=N.

Jump to

Keyboard shortcuts

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