Documentation
¶
Overview ¶
Package rest implements Githome's REST API v3. It mounts onto a mizu router and is the only place HTTP request handling for the REST surface lives. Handlers call the domain layer for data and the presenter layer for rendering; they never touch the store or git directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mount ¶
Mount wires the REST routes onto root. The API is served both at the GHES-style /api/v3 prefix and at the bare github.com-style root, sharing one set of handlers and the version/media-type middleware. Health probes sit outside that chain, and any unmatched path returns the GitHub-shaped 404.
Types ¶
type Deps ¶
type Deps struct {
Config config.Config
Logger *slog.Logger
Ready Pinger
Auth *auth.Service
Users *domain.UserService
Repos *domain.RepoService
Issues *domain.IssueService
Pulls *domain.PRService
Reviews *domain.ReviewService
Checks *domain.ChecksService
Hooks *domain.HookService
Events *domain.EventService
Search *domain.SearchService
URLs *presenter.URLBuilder
NodeFormat nodeid.Format
}
Deps are the dependencies the REST surface needs to mount. The auth, domain, and presenter members arrive in M1; a zero member leaves its routes unmounted, which keeps the M0 foundation tests able to build a minimal surface.
type FieldError ¶
type FieldError struct {
Resource string `json:"resource"`
Field string `json:"field"`
Code string `json:"code"`
Message string `json:"message,omitempty"`
}
FieldError is one entry in a 422 validation error's errors array. Code is one of: missing, missing_field, invalid, already_exists, unprocessable, custom.
type Page ¶
Page is one page of a list response. Page and PerPage come from the request; Total is filled in by the handler from the domain count once the page is fetched, and finalize derives the navigation flags the Link header needs.
func (Page) HasNextPage ¶ added in v0.1.1
HasNextPage reports whether there is at least one more page after this one, using the Total set by the handler. It is called before finalize so the handler can decide whether to build a cursor before writing the Link header.