presenter

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GQLAuthorAssociation added in v0.1.3

func GQLAuthorAssociation(owner string, u *domain.User) gqlmodel.CommentAuthorAssociation

GQLAuthorAssociation is the GraphQL spelling of the REST authorAssociation heuristic: the repository owner is OWNER; anyone else is NONE until collaborator and member roles are modeled. A ghost author is NONE.

func GQLCheckRun added in v0.1.3

func GQLCheckRun(cr *domain.CheckRun, format nodeid.Format) gqlmodel.CheckRun

GQLCheckRun renders a domain CheckRun into the GraphQL CheckRun shape.

func GQLCommit added in v0.1.3

func GQLCommit(repoDBID int64, owner, name string, c git.Commit) *gqlmodel.Commit

GQLCommit renders a git commit into the GraphQL Commit shape. repoDBID is the repository's public database id the node id encodes; owner and name are the coordinates the statusCheckRollup resolver reads back.

func GQLReactionContent added in v0.1.3

func GQLReactionContent(rest string) gqlmodel.ReactionContent

GQLReactionContent maps a domain reaction content (GitHub's REST emoji name) onto the GraphQL ReactionContent enum.

func GQLReactionGroupsFromList added in v0.1.3

func GQLReactionGroupsFromList(rs []*domain.Reaction) []*gqlmodel.ReactionGroup

GQLReactionGroupsFromList summarizes a list of domain reactions into the GraphQL reaction groups, the subject-level rollup addReaction and removeReaction return after the change. The slice is non-nil even when empty.

func GQLRef added in v0.1.3

func GQLRef(repoID int64, qualifiedName, shortName, sha string) *gqlmodel.Ref

GQLRef renders a git reference into the GraphQL Ref shape. repoID is the repository's public database ID used to encode the node ID, the same id the REST presenter encodes, so a node_id from either API names the same ref; qualifiedName is the full ref path (refs/heads/main); shortName is the bare ref name (main); sha is the target commit's SHA.

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, _ nodeid.Format) *gqlmodel.StatusCheckRollup

GQLStatusCheckRollup renders a domain rollup into the GraphQL shape. The contexts field is resolved lazily; the repo coordinates are embedded so the contexts resolver can re-fetch the full rollup from the domain.

func GQLStatusCheckRollupFor added in v0.1.3

func GQLStatusCheckRollupFor(r *domain.StatusCheckRollup, owner, repo string, _ nodeid.Format) *gqlmodel.StatusCheckRollup

GQLStatusCheckRollupFor is like GQLStatusCheckRollup but also carries the repo coordinates the contexts resolver needs to re-fetch the full domain data.

func GQLStatusContext added in v0.1.3

func GQLStatusContext(s *domain.CommitStatus) gqlmodel.StatusContext

GQLStatusContext renders a domain CommitStatus into the GraphQL StatusContext 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 RESTReactionContent added in v0.1.3

func RESTReactionContent(c gqlmodel.ReactionContent) string

RESTReactionContent maps a GraphQL ReactionContent enum value onto the domain reaction content (GitHub's REST emoji name) the reaction service stores. An unknown value passes through unchanged so the domain layer rejects it.

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 RepoDetail added in v0.1.3

type RepoDetail struct {
	NetworkCount     int
	SubscribersCount int
	Organization     *domain.User
	Parent           *restmodel.Repository
	Source           *restmodel.Repository
}

RepoDetail carries the extras only the single-repository responses render: the fork counts, the organization block, and the resolved fork parent and source. The handler assembles it; the presenter stays pure.

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

func (b *URLBuilder) Blob(owner, repoName string, repoDBID int64, blob git.Blob) restmodel.Blob

Blob renders GET /git/blobs/{sha} with base64-wrapped content.

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) CheckRunAnnotation added in v0.1.3

func (b *URLBuilder) CheckRunAnnotation(owner, repo, headSHA string, a *domain.CheckRunAnnotation) restmodel.CheckRunAnnotation

CheckRunAnnotation renders one check run annotation for owner/repo. The blob href addresses the annotated file at the run's head sha.

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) CodeownersErrors added in v0.1.3

func (b *URLBuilder) CodeownersErrors(errs []domain.CodeownerError) restmodel.CodeownersErrors

CodeownersErrors renders the validation errors found in a repository's CODEOWNERS file.

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) CommunityProfile added in v0.1.3

func (b *URLBuilder) CommunityProfile(owner, repoName, ref string, p domain.CommunityProfile, description *string) restmodel.CommunityProfile

CommunityProfile renders a repository's community-health profile, expanding each present file into its contents-API url and blob html_url at the default branch.

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) ContentEntry added in v0.1.3

func (b *URLBuilder) ContentEntry(owner, repoName, ref string, e git.PathEntry) restmodel.Content

ContentEntry renders the content object without the body, the shape the contents PUT and DELETE responses embed.

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 (b *URLBuilder) CursorLink(path, rawQuery, cursor string, page int) string

CursorLink returns the URL for the next page identified by an opaque cursor. It carries per_page through from the original query and replaces the page and cursor parameters. page is the page number the cursor lands on; carrying it alongside the cursor lets the follow-up request know where it is, so it can offer rel="prev" and rel="first" page-number links, and lets clients that parse page out of Link URLs (go-github fills NextPage this way) keep working on the cursor path. A page below 1 drops the parameter.

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 labels, assignees, and milestone eagerly from the pre-loaded domain data; comments carry the total only and are paged by the resolver on demand. 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. The author association is the owner heuristic Githome applies everywhere: the repository owner is OWNER, everyone else is NONE until collaborator roles are modeled. includesCreatedEdit falls out of the timestamps.

func (*URLBuilder) GQLLabel

func (b *URLBuilder) GQLLabel(owner, repo string, l *domain.Label, format nodeid.Format) *gqlmodel.Label

GQLLabel renders a domain label into the GraphQL Label shape. owner and repo name the repository the label belongs to, used to build the label's HTML URL (the label-filtered issue list, matching GitHub). Githome does not track a separate label-update instant, so updatedAt mirrors createdAt.

func (*URLBuilder) GQLMilestone added in v0.1.3

func (b *URLBuilder) GQLMilestone(owner, repo string, m *domain.Milestone, format nodeid.Format) *gqlmodel.Milestone

GQLMilestone renders a domain milestone into the GraphQL Milestone 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) GQLReaction added in v0.1.3

func (b *URLBuilder) GQLReaction(r *domain.Reaction, format nodeid.Format) *gqlmodel.Reaction

GQLReaction renders a domain reaction into the GraphQL Reaction shape, the node addReaction and removeReaction return. The user is rendered through the shared actor path, null for a ghost user. format selects the node-ID encoding.

func (*URLBuilder) GQLRelease added in v0.1.3

func (b *URLBuilder) GQLRelease(owner, repo string, rel *domain.Release, isLatest bool, format nodeid.Format) *gqlmodel.Release

GQLRelease renders a domain release into the GraphQL Release shape. isLatest is whether this is the repository's most recent published release.

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. format selects the node-ID encoding.

func (*URLBuilder) GQLRepositoryOwner added in v0.1.3

func (b *URLBuilder) GQLRepositoryOwner(u *domain.User, format nodeid.Format) gqlmodel.RepositoryOwner

GQLRepositoryOwner renders a repository's owner into the GraphQL RepositoryOwner shape. The concrete value is always a *gqlmodel.User so inline fragments dispatch; a nil user renders to null.

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) GQLUser added in v0.1.3

func (b *URLBuilder) GQLUser(u *domain.User, format nodeid.Format) *gqlmodel.User

GQLUser renders a domain user into the GraphQL User shape.

func (*URLBuilder) GQLUserConnection added in v0.1.3

func (b *URLBuilder) GQLUserConnection(users []*domain.User, format nodeid.Format) *gqlmodel.UserConnection

GQLUserConnection renders a slice of domain users into a UserConnection.

func (*URLBuilder) GeneratedNotes added in v0.1.3

func (b *URLBuilder) GeneratedNotes(owner, repo string, n *domain.GeneratedNotes) restmodel.GeneratedNotes

GeneratedNotes renders POST /releases/generate-notes: GitHub's "What's Changed" markdown built from the release's commit range, closed by a Full Changelog link that compares against the previous tag when one exists.

func (*URLBuilder) Gist added in v0.1.3

func (b *URLBuilder) Gist(g *store.GistRow, owner *domain.User, commentCount int, format nodeid.Format) restmodel.Gist

Gist renders a store.GistRow (with its resolved owner) into the REST wire model. commentCount is the pre-fetched number of comments for this gist.

func (*URLBuilder) GistComment added in v0.1.3

func (b *URLBuilder) GistComment(c *store.GistCommentRow, user *domain.User, format nodeid.Format) restmodel.GistComment

GistComment renders a store.GistCommentRow into the REST wire model.

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

func (b *URLBuilder) Hook(owner, repo string, h *domain.Hook) restmodel.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) IssueEvent added in v0.1.3

func (b *URLBuilder) IssueEvent(owner, repo string, e *domain.IssueEvent, format nodeid.Format) restmodel.IssueEvent

IssueEvent renders one entry of an issue's event log for owner/repo. The URL addresses the event under the repository's issues/events collection, matching GitHub. commit_id/commit_url stay null: the action events githome records do not reference a commit. A nil actor renders as JSON null.

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) NotificationSubscription added in v0.1.3

func (b *URLBuilder) NotificationSubscription(t *domain.NotificationThread) restmodel.NotificationSubscription

NotificationSubscription renders the thread's subscription state.

func (*URLBuilder) NotificationThread added in v0.1.3

func (b *URLBuilder) NotificationThread(t *domain.NotificationThread, repo *domain.Repo, format nodeid.Format) restmodel.NotificationThread

NotificationThread renders one thread for the notifications endpoints. The subject URL points at the issue or pull request API object, and the latest comment URL falls back to the subject itself when no comment is newer, the same fallback GitHub uses.

func (*URLBuilder) OrgHook added in v0.1.3

func (b *URLBuilder) OrgHook(org string, h *domain.Hook) restmodel.Hook

OrgHook renders an organization webhook. Storage rides the synthetic _org repo, but the wire shape lives in the /orgs URL space with type Organization and no test_url, matching github.com.

func (*URLBuilder) OrgMembership added in v0.1.3

func (b *URLBuilder) OrgMembership(org, user *domain.User, role string, format nodeid.Format) restmodel.OrgMembership

OrgMembership renders one membership for GET /user/memberships/orgs. The org is the member's organization and user is the member account.

func (*URLBuilder) OrgSimple added in v0.1.3

func (b *URLBuilder) OrgSimple(u *domain.User, format nodeid.Format) restmodel.OrganizationSimple

OrgSimple renders the trimmed org shape used inside list payloads such as GET /user/orgs.

func (*URLBuilder) Organization added in v0.1.3

func (b *URLBuilder) Organization(u *domain.User, format nodeid.Format) restmodel.Organization

Organization renders the org profile for GET /orgs/{org}. Orgs share the users table, so u is the backing user account; the bio doubles as the org description.

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, and cursor, which is dropped because a page-number link addresses a position, not a keyset. 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) Reaction

func (b *URLBuilder) Reaction(r *domain.Reaction, format nodeid.Format) restmodel.Reaction

Reaction renders a single reaction.

func (*URLBuilder) Release added in v0.1.3

func (b *URLBuilder) Release(owner, repo string, r *domain.Release, format nodeid.Format) restmodel.Release

Release renders a domain.Release into the REST wire model.

func (*URLBuilder) ReleaseAsset added in v0.1.3

func (b *URLBuilder) ReleaseAsset(owner, repo string, releaseID int64, a *domain.ReleaseAsset, format nodeid.Format) restmodel.ReleaseAsset

ReleaseAsset renders a domain.ReleaseAsset into the REST wire model.

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) RepoSubscription added in v0.1.3

func (b *URLBuilder) RepoSubscription(s *domain.Subscription) restmodel.RepoSubscription

RepoSubscription renders a repository subscription. The url is the subscription endpoint and repository_url the repository itself, the pair GitHub returns on this body.

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) RepositoryFull added in v0.1.3

func (b *URLBuilder) RepositoryFull(r *domain.Repo, format nodeid.Format, perm *restmodel.RepoPermissions, det RepoDetail) restmodel.Repository

RepositoryFull renders the single-repository shape: the list shape plus the always-null temp_clone_token, the network and subscriber counts, the organization for org-owned repos, the fork parent/source, and, when the caller administers the repository, the merge-policy settings. GitHub scopes the merge settings to admins, so they key off perm.Admin.

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) SearchUsers added in v0.1.3

func (b *URLBuilder) SearchUsers(users []*domain.User, total int, incomplete bool, format nodeid.Format) restmodel.SearchUsers

SearchUsers renders the user search envelope. Each hit is a SimpleUser, the shape GitHub returns for account search rather than the full profile.

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 (b *URLBuilder) SinceLink(path, rawQuery string, since int64) string

SinceLink returns the URL for the next page of an id-cursor listing such as GET /users: it carries every query parameter through unchanged except since, which is set to the last id seen, and page, which is dropped because an id-cursor addresses a position rather than a page number.

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

func (b *URLBuilder) Tag(owner, repoName string, repoDBID int64, t git.Tag) restmodel.Tag

Tag renders one element of GET /tags.

func (*URLBuilder) Tree

func (b *URLBuilder) Tree(owner, repoName string, t git.Tree) restmodel.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

func (b *URLBuilder) User(u *domain.User, format nodeid.Format, authenticated bool) restmodel.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}.

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.

Jump to

Keyboard shortcuts

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