Documentation
¶
Overview ¶
Package presenter renders domain values into the exact wire shapes GitHub emits. The urlbuilder defined here owns every URL that appears in a response, so links are always built from the configured host and the two API surfaces cannot disagree about a resource's URLs.
Index ¶
- func GQLReviewDecision(decision *string) *gqlmodel.PullRequestReviewDecision
- func GQLStatusCheckRollup(r *domain.StatusCheckRollup) *gqlmodel.StatusCheckRollup
- func OwnerPermissions() *restmodel.RepoPermissions
- func ReadPermissions() *restmodel.RepoPermissions
- type URLBuilder
- func (b *URLBuilder) API(segments ...string) string
- func (b *URLBuilder) APIBase() string
- func (b *URLBuilder) Blob(owner, repoName string, repoDBID int64, blob git.Blob) restmodel.Blob
- func (b *URLBuilder) Branch(owner, repoName string, repoDBID int64, br git.Branch, head git.Commit) restmodel.Branch
- func (b *URLBuilder) BranchShort(owner, repoName string, br git.Branch) restmodel.BranchShort
- func (b *URLBuilder) CheckRun(owner, repo string, r *domain.CheckRun, format nodeid.Format) restmodel.CheckRun
- func (b *URLBuilder) CheckRunList(owner, repo string, runs []*domain.CheckRun, format nodeid.Format) restmodel.CheckRunList
- func (b *URLBuilder) CheckSuite(owner, repo string, s *domain.CheckSuite, format nodeid.Format) restmodel.CheckSuite
- func (b *URLBuilder) CheckSuiteList(owner, repo string, suites []*domain.CheckSuite, format nodeid.Format) restmodel.CheckSuiteList
- func (b *URLBuilder) CombinedStatus(owner, repo string, cs *domain.CombinedStatus, format nodeid.Format) restmodel.CombinedStatus
- func (b *URLBuilder) ContentDir(owner, repoName, ref string, entries []git.PathEntry) []restmodel.Content
- func (b *URLBuilder) ContentFile(owner, repoName, ref string, e git.PathEntry, content []byte) restmodel.Content
- func (b *URLBuilder) CursorLink(path, rawQuery, cursor string) string
- func (b *URLBuilder) Event(e *domain.Event) restmodel.Event
- func (b *URLBuilder) GQLIssue(owner, repo string, iss *domain.Issue, format nodeid.Format) *gqlmodel.Issue
- func (b *URLBuilder) GQLIssueComment(owner, repo string, cm *domain.Comment, format nodeid.Format) *gqlmodel.IssueComment
- func (b *URLBuilder) GQLLabel(l *domain.Label, format nodeid.Format) *gqlmodel.Label
- func (b *URLBuilder) GQLPullRequest(owner, repo string, pr *domain.PullRequest, format nodeid.Format) *gqlmodel.PullRequest
- func (b *URLBuilder) GQLPullRequestChangedFile(f git.FileChange) *gqlmodel.PullRequestChangedFile
- func (b *URLBuilder) GQLPullRequestCommit(owner, repo string, c git.Commit) *gqlmodel.PullRequestCommit
- func (b *URLBuilder) GQLRepository(r *domain.Repo, branch *git.Branch, format nodeid.Format) gqlmodel.Repository
- func (b *URLBuilder) GQLReviewComment(owner, repo string, c *domain.ReviewComment, format nodeid.Format) *gqlmodel.PullRequestReviewComment
- func (b *URLBuilder) GQLReviewThread(owner, repo string, t *domain.ReviewThread, format nodeid.Format) *gqlmodel.PullRequestReviewThread
- func (b *URLBuilder) GitCommit(owner, repoName string, repoDBID int64, c git.Commit) restmodel.GitCommit
- func (b *URLBuilder) GitRef(owner, repoName string, repoDBID int64, ref git.Ref) restmodel.GitRefObject
- func (b *URLBuilder) GraphQLEndpoint() string
- func (b *URLBuilder) HTML(segments ...string) string
- func (b *URLBuilder) HTMLBase() string
- func (b *URLBuilder) Hook(owner, repo string, h *domain.Hook) restmodel.Hook
- func (b *URLBuilder) HookDelivery(owner, repo string, hookID int64, d *domain.HookDelivery) restmodel.HookDelivery
- func (b *URLBuilder) Issue(owner, repo string, iss *domain.Issue, format nodeid.Format) restmodel.Issue
- func (b *URLBuilder) IssueComment(owner, repo string, cm *domain.Comment, format nodeid.Format) restmodel.IssueComment
- func (b *URLBuilder) Label(owner, repo string, l *domain.Label, format nodeid.Format) restmodel.Label
- func (b *URLBuilder) Milestone(owner, repo string, m *domain.Milestone, format nodeid.Format) restmodel.Milestone
- func (b *URLBuilder) PageLink(path, rawQuery string, page int) string
- func (b *URLBuilder) PullRequest(owner, repo string, pr *domain.PullRequest, format nodeid.Format, detail bool) restmodel.PullRequest
- func (b *URLBuilder) PullRequestFile(owner, repo, headSHA string, f git.FileChange) restmodel.PullRequestFile
- func (b *URLBuilder) PullRequestMergeResult(r *domain.MergeResult) restmodel.PullRequestMergeResult
- func (b *URLBuilder) Reaction(r *domain.Reaction, format nodeid.Format) restmodel.Reaction
- func (b *URLBuilder) RepoAPI(owner, repo string) string
- func (b *URLBuilder) RepoCommit(owner, repoName string, repoDBID int64, c git.Commit) restmodel.RepoCommit
- func (b *URLBuilder) RepoGitHTTP(owner, repo string) string
- func (b *URLBuilder) RepoGitProto(owner, repo string) string
- func (b *URLBuilder) RepoGitSSH(owner, repo string) string
- func (b *URLBuilder) RepoHTML(owner, repo string) string
- func (b *URLBuilder) Repository(r *domain.Repo, format nodeid.Format, perm *restmodel.RepoPermissions) restmodel.Repository
- func (b *URLBuilder) Review(owner, repo string, r *domain.Review, format nodeid.Format) restmodel.Review
- func (b *URLBuilder) ReviewComment(owner, repo string, c *domain.ReviewComment, format nodeid.Format) restmodel.ReviewComment
- func (b *URLBuilder) SearchCode(results []domain.CodeResult, total int, incomplete bool, format nodeid.Format) restmodel.SearchCode
- func (b *URLBuilder) SearchIssues(hits []domain.IssueHit, total int, incomplete bool, format nodeid.Format) restmodel.SearchIssues
- func (b *URLBuilder) SearchRepositories(repos []*domain.Repo, total int, incomplete bool, format nodeid.Format) restmodel.SearchRepositories
- func (b *URLBuilder) SimpleUser(u *domain.User, format nodeid.Format) restmodel.SimpleUser
- func (b *URLBuilder) Status(owner, repo string, s *domain.CommitStatus, format nodeid.Format) restmodel.Status
- func (b *URLBuilder) Tag(owner, repoName string, repoDBID int64, t git.Tag) restmodel.Tag
- func (b *URLBuilder) Tree(owner, repoName string, t git.Tree) restmodel.Tree
- func (b *URLBuilder) User(u *domain.User, format nodeid.Format, authenticated bool) restmodel.User
- func (b *URLBuilder) UserAPI(login string) string
- func (b *URLBuilder) UserHTML(login string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GQLReviewDecision ¶
func GQLReviewDecision(decision *string) *gqlmodel.PullRequestReviewDecision
GQLReviewDecision maps a domain review decision string to the GraphQL enum, returning nil when no review blocks or approves the pull request.
func GQLStatusCheckRollup ¶
func GQLStatusCheckRollup(r *domain.StatusCheckRollup) *gqlmodel.StatusCheckRollup
GQLStatusCheckRollup renders a domain rollup into the GraphQL shape.
func OwnerPermissions ¶
func OwnerPermissions() *restmodel.RepoPermissions
OwnerPermissions is the all-true permission block GitHub returns for a repository's owner or an admin.
func ReadPermissions ¶
func ReadPermissions() *restmodel.RepoPermissions
ReadPermissions is the pull-only block for an authenticated user with read access to a repository they do not administer.
Types ¶
type URLBuilder ¶
type URLBuilder struct {
// contains filtered or unexported fields
}
URLBuilder constructs the absolute URLs that responses embed. It is created once from the resolved configuration and is safe for concurrent use.
func NewURLBuilder ¶
func NewURLBuilder(u config.URLs) *URLBuilder
NewURLBuilder builds a URLBuilder from the resolved config URLs.
func (*URLBuilder) API ¶
func (b *URLBuilder) API(segments ...string) string
API joins path segments onto the API base.
func (*URLBuilder) APIBase ¶
func (b *URLBuilder) APIBase() string
APIBase returns the API root, e.g. https://git.example.com/api/v3.
func (*URLBuilder) Branch ¶
func (b *URLBuilder) Branch(owner, repoName string, repoDBID int64, br git.Branch, head git.Commit) restmodel.Branch
Branch renders GET /branches/{branch} with the branch's full head commit and its (always disabled, for now) protection summary.
func (*URLBuilder) BranchShort ¶
func (b *URLBuilder) BranchShort(owner, repoName string, br git.Branch) restmodel.BranchShort
BranchShort renders one element of GET /branches.
func (*URLBuilder) CheckRun ¶
func (b *URLBuilder) CheckRun(owner, repo string, r *domain.CheckRun, format nodeid.Format) restmodel.CheckRun
CheckRun renders one check run for owner/repo. The node id encodes the run's own id under the CheckRun kind; the urls address the run and its details.
func (*URLBuilder) CheckRunList ¶
func (b *URLBuilder) CheckRunList(owner, repo string, runs []*domain.CheckRun, format nodeid.Format) restmodel.CheckRunList
CheckRunList renders the check-runs collection for owner/repo at a ref.
func (*URLBuilder) CheckSuite ¶
func (b *URLBuilder) CheckSuite(owner, repo string, s *domain.CheckSuite, format nodeid.Format) restmodel.CheckSuite
CheckSuite renders one check suite for owner/repo.
func (*URLBuilder) CheckSuiteList ¶
func (b *URLBuilder) CheckSuiteList(owner, repo string, suites []*domain.CheckSuite, format nodeid.Format) restmodel.CheckSuiteList
CheckSuiteList renders the check-suites collection for owner/repo at a ref.
func (*URLBuilder) CombinedStatus ¶
func (b *URLBuilder) CombinedStatus(owner, repo string, cs *domain.CombinedStatus, format nodeid.Format) restmodel.CombinedStatus
CombinedStatus renders the combined status for owner/repo at a sha, folding the contributing statuses and a minimal repository.
func (*URLBuilder) ContentDir ¶
func (b *URLBuilder) ContentDir(owner, repoName, ref string, entries []git.PathEntry) []restmodel.Content
ContentDir renders a directory listing: one entry per immediate child, with encoding and content omitted and a null download_url for sub-directories.
func (*URLBuilder) ContentFile ¶
func (b *URLBuilder) ContentFile(owner, repoName, ref string, e git.PathEntry, content []byte) restmodel.Content
ContentFile renders a single file's contents response. The body carries the base64-wrapped content GitHub emits; ref is the revision the path was read at and is echoed into the url query and the blob/raw links.
func (*URLBuilder) CursorLink ¶ added in v0.1.1
func (b *URLBuilder) CursorLink(path, rawQuery, cursor string) string
CursorLink returns the URL for the next page identified by an opaque cursor. It carries per_page through from the original query and drops the page and cursor parameters so the link is a clean cursor reference.
func (*URLBuilder) Event ¶
func (b *URLBuilder) Event(e *domain.Event) restmodel.Event
Event renders one activity-feed entry. id is the database id as a string, and actor and repo are the compact forms the Events API embeds rather than the full objects the payload carries. The payload is served verbatim: it was rendered and stored when the event fanned out.
func (*URLBuilder) GQLIssue ¶
func (b *URLBuilder) GQLIssue(owner, repo string, iss *domain.Issue, format nodeid.Format) *gqlmodel.Issue
GQLIssue renders a domain issue into the GraphQL Issue shape for owner/repo. It fills the embedded label connection from the issue's attached labels and a comment connection carrying the total; the resolver attaches comment nodes when a query selects them. format selects the node-ID encoding.
func (*URLBuilder) GQLIssueComment ¶
func (b *URLBuilder) GQLIssueComment(owner, repo string, cm *domain.Comment, format nodeid.Format) *gqlmodel.IssueComment
GQLIssueComment renders a domain comment into the GraphQL IssueComment shape.
func (*URLBuilder) GQLPullRequest ¶
func (b *URLBuilder) GQLPullRequest(owner, repo string, pr *domain.PullRequest, format nodeid.Format) *gqlmodel.PullRequest
GQLPullRequest renders a domain pull request into the GraphQL PullRequest shape for owner/repo. It fills the merge view from the worker-resolved state: a nil Mergeable is UNKNOWN, the null-then-value contract a poll resolves. The files and commits connections are paged through the git layer by their own resolvers; the presenter fills only the repository coordinates they read.
func (*URLBuilder) GQLPullRequestChangedFile ¶
func (b *URLBuilder) GQLPullRequestChangedFile(f git.FileChange) *gqlmodel.PullRequestChangedFile
GQLPullRequestChangedFile renders a git file change into the GraphQL changed file shape.
func (*URLBuilder) GQLPullRequestCommit ¶
func (b *URLBuilder) GQLPullRequestCommit(owner, repo string, c git.Commit) *gqlmodel.PullRequestCommit
GQLPullRequestCommit renders a git commit into the GraphQL pull request commit shape, the {url, commit} wrapper GitHub nests a commit in.
func (*URLBuilder) GQLRepository ¶
func (b *URLBuilder) GQLRepository(r *domain.Repo, branch *git.Branch, format nodeid.Format) gqlmodel.Repository
GQLRepository renders a domain repository into the GraphQL Repository shape. branch is the resolved default-branch ref, or nil for a repository with no commits, in which case defaultBranchRef and pushedAt come back null just as GitHub returns them. format selects the node-ID encoding.
func (*URLBuilder) GQLReviewComment ¶
func (b *URLBuilder) GQLReviewComment(owner, repo string, c *domain.ReviewComment, format nodeid.Format) *gqlmodel.PullRequestReviewComment
GQLReviewComment renders a domain review comment into the GraphQL shape. The url addresses the comment's discussion fragment on the pull request page.
func (*URLBuilder) GQLReviewThread ¶
func (b *URLBuilder) GQLReviewThread(owner, repo string, t *domain.ReviewThread, format nodeid.Format) *gqlmodel.PullRequestReviewThread
GQLReviewThread renders a domain review thread into the GraphQL shape for owner/repo, folding in its comments connection. The node id encodes the thread's root comment id under the review-thread kind.
func (*URLBuilder) GitCommit ¶
func (b *URLBuilder) GitCommit(owner, repoName string, repoDBID int64, c git.Commit) restmodel.GitCommit
GitCommit renders GET /git/commits/{sha}, the git-database view of a commit.
func (*URLBuilder) GitRef ¶
func (b *URLBuilder) GitRef(owner, repoName string, repoDBID int64, ref git.Ref) restmodel.GitRefObject
GitRef renders GET /git/ref/{ref} and one element of GET /git/refs.
func (*URLBuilder) GraphQLEndpoint ¶
func (b *URLBuilder) GraphQLEndpoint() string
GraphQLEndpoint returns the GraphQL endpoint URL.
func (*URLBuilder) HTML ¶
func (b *URLBuilder) HTML(segments ...string) string
HTML joins path segments onto the site base.
func (*URLBuilder) HTMLBase ¶
func (b *URLBuilder) HTMLBase() string
HTMLBase returns the site root, e.g. https://git.example.com.
func (*URLBuilder) Hook ¶
Hook renders a repository webhook. The secret is never on the wire: when the hook has one, config.secret is the fixed mask, and when it does not the field is omitted, matching github.com.
func (*URLBuilder) HookDelivery ¶
func (b *URLBuilder) HookDelivery(owner, repo string, hookID int64, d *domain.HookDelivery) restmodel.HookDelivery
HookDelivery renders one delivery. full controls whether the request and response bodies are present: the list omits them, the single-delivery GET includes them.
func (*URLBuilder) Issue ¶
func (b *URLBuilder) Issue(owner, repo string, iss *domain.Issue, format nodeid.Format) restmodel.Issue
Issue renders the full issue object for owner/repo. It is pure: the same domain issue, URL config, and node-id format always produce the same bytes. The URLs all hang off the repository's API base so the two API surfaces agree about an issue's links.
func (*URLBuilder) IssueComment ¶
func (b *URLBuilder) IssueComment(owner, repo string, cm *domain.Comment, format nodeid.Format) restmodel.IssueComment
IssueComment renders an issue comment for owner/repo. The comment carries the number of the issue it belongs to so its html_url and issue_url resolve.
func (*URLBuilder) Label ¶
func (b *URLBuilder) Label(owner, repo string, l *domain.Label, format nodeid.Format) restmodel.Label
Label renders a repository label for owner/repo. The label URL escapes the name so labels with spaces or slashes address correctly.
func (*URLBuilder) Milestone ¶
func (b *URLBuilder) Milestone(owner, repo string, m *domain.Milestone, format nodeid.Format) restmodel.Milestone
Milestone renders a milestone for owner/repo, including the open and closed issue counts the domain computed on read.
func (*URLBuilder) PageLink ¶
func (b *URLBuilder) PageLink(path, rawQuery string, page int) string
PageLink returns the absolute URL a Link header rel points at: the given request path on the configured API host, carrying every query parameter through unchanged except page, which is set to the target. Building it on the API host (never the inbound Host header) keeps the link on the Githome host the same way every other embedded URL is.
func (*URLBuilder) PullRequest ¶
func (b *URLBuilder) PullRequest(owner, repo string, pr *domain.PullRequest, format nodeid.Format, detail bool) restmodel.PullRequest
PullRequest renders the full pull request object for owner/repo. It is pure: the same domain pull request, URL config, and node-id format always produce the same bytes. detail controls the merge view: the single-pull endpoint passes true to fill merged, the mergeable triplet, and the diff stats, while the list endpoint passes false so those fields drop out, matching GitHub where a listed pull request carries only its summary. The REST id is the issue row's id, the shared id space a pull request and its issue occupy; the node id encodes the pull request's own id under the PullRequest kind.
func (*URLBuilder) PullRequestFile ¶
func (b *URLBuilder) PullRequestFile(owner, repo, headSHA string, f git.FileChange) restmodel.PullRequestFile
PullRequestFile renders one element of the files endpoint from a git file change. The blob and raw URLs hang off the head sha so they address the file as the pull request leaves it; the contents URL points at the same ref.
func (*URLBuilder) PullRequestMergeResult ¶
func (b *URLBuilder) PullRequestMergeResult(r *domain.MergeResult) restmodel.PullRequestMergeResult
PullRequestMergeResult renders the body of a successful merge.
func (*URLBuilder) RepoAPI ¶
func (b *URLBuilder) RepoAPI(owner, repo string) string
RepoAPI returns the API URL for a repository.
func (*URLBuilder) RepoCommit ¶
func (b *URLBuilder) RepoCommit(owner, repoName string, repoDBID int64, c git.Commit) restmodel.RepoCommit
RepoCommit renders one element of GET /commits and the commit a single branch embeds. The matched author/committer accounts are null until email-to-account mapping lands.
func (*URLBuilder) RepoGitHTTP ¶
func (b *URLBuilder) RepoGitHTTP(owner, repo string) string
RepoGitHTTP returns the smart-HTTP clone URL, e.g. {html}/{owner}/{repo}.git.
func (*URLBuilder) RepoGitProto ¶
func (b *URLBuilder) RepoGitProto(owner, repo string) string
RepoGitProto returns the anonymous git-protocol URL, e.g. git://{host}/{owner}/{repo}.git, built from the site host.
func (*URLBuilder) RepoGitSSH ¶
func (b *URLBuilder) RepoGitSSH(owner, repo string) string
RepoGitSSH returns the SSH clone URL, omitting the port when it is the default 22, matching GitHub's scp-like form.
func (*URLBuilder) RepoHTML ¶
func (b *URLBuilder) RepoHTML(owner, repo string) string
RepoHTML returns the site URL for a repository.
func (*URLBuilder) Repository ¶
func (b *URLBuilder) Repository(r *domain.Repo, format nodeid.Format, perm *restmodel.RepoPermissions) restmodel.Repository
Repository renders the full repository object. It is pure: the same domain repo, URL config, node-id format, and permissions always produce the same bytes. perm is the actor's effective access, or nil to omit the permissions block (anonymous requests). Language and license are always null for now; counters Githome does not track yet report zero.
func (*URLBuilder) Review ¶
func (b *URLBuilder) Review(owner, repo string, r *domain.Review, format nodeid.Format) restmodel.Review
Review renders one review object for owner/repo. The node id encodes the review's own id under the PullRequestReview kind; the html anchor and the pull request url hang off the pull request number the review belongs to.
func (*URLBuilder) ReviewComment ¶
func (b *URLBuilder) ReviewComment(owner, repo string, c *domain.ReviewComment, format nodeid.Format) restmodel.ReviewComment
ReviewComment renders one inline comment for owner/repo. Both the line/side anchor and the legacy position are rendered; original_* mirror the values as the comment was first written.
func (*URLBuilder) SearchCode ¶
func (b *URLBuilder) SearchCode(results []domain.CodeResult, total int, incomplete bool, format nodeid.Format) restmodel.SearchCode
SearchCode renders the code search envelope. The file's url addresses it through the contents API at the matched ref, git_url through the blob API, and html_url through the repository's default branch, the three links GitHub returns on a code hit.
func (*URLBuilder) SearchIssues ¶
func (b *URLBuilder) SearchIssues(hits []domain.IssueHit, total int, incomplete bool, format nodeid.Format) restmodel.SearchIssues
SearchIssues renders the issue search envelope. Each hit carries the repository it belongs to so its URLs resolve, since a cross-repository search returns issues whose owner and name are not implied by the request path.
func (*URLBuilder) SearchRepositories ¶
func (b *URLBuilder) SearchRepositories(repos []*domain.Repo, total int, incomplete bool, format nodeid.Format) restmodel.SearchRepositories
SearchRepositories renders the repository search envelope.
func (*URLBuilder) SimpleUser ¶
func (b *URLBuilder) SimpleUser(u *domain.User, format nodeid.Format) restmodel.SimpleUser
SimpleUser renders the embedded actor object for u. It is pure: the same domain user, URL config, and node-id format always produce the same bytes.
func (*URLBuilder) Status ¶
func (b *URLBuilder) Status(owner, repo string, s *domain.CommitStatus, format nodeid.Format) restmodel.Status
Status renders one commit status for owner/repo. The node id encodes the status's own id under the StatusContext kind; the url addresses the statuses collection at the sha the status anchors to.
func (*URLBuilder) Tree ¶
Tree renders GET /git/trees/{sha}. Blob entries carry size and a blob url, subtree entries a tree url and no size, and submodule entries neither.
func (*URLBuilder) User ¶
User renders the full profile. When authenticated is true (GET /user for the viewer themselves), the private counters GitHub only shows the account owner are included; otherwise they are omitted.
func (*URLBuilder) UserAPI ¶
func (b *URLBuilder) UserAPI(login string) string
UserAPI returns the API URL for a user, e.g. {api}/users/{login}.
func (*URLBuilder) UserHTML ¶
func (b *URLBuilder) UserHTML(login string) string
UserHTML returns the site URL for a user, e.g. {html}/{login}.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gqlmodel holds the hand-written Go types that back Githome's GraphQL object types and scalars.
|
Package gqlmodel holds the hand-written Go types that back Githome's GraphQL object types and scalars. |
|
Package restmodel holds the exact JSON wire structs Githome serves on the REST API.
|
Package restmodel holds the exact JSON wire structs Githome serves on the REST API. |