Documentation
¶
Overview ¶
Package ghapi holds the GitHub-specific plumbing shared by the GitHub-API based sources (github-release, github-tag): the default base URL, the "owner/name" coordinate parser and the authenticated GET helper. The token and redirect plumbing is in package apiclient.
It is internal to internal/source and carries no source-specific logic.
Index ¶
Constants ¶
const DefaultBaseURL = "https://api.github.com"
DefaultBaseURL is the GitHub.com API. For GitHub Enterprise use "https://HOST/api/v3".
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client sends GitHub API requests.
func New ¶
New returns a Client for baseURL (DefaultBaseURL if empty) using hc, normally the netguard client. hc must not be nil. An invalid baseURL, or a token with a plain-http non-loopback base URL, does not panic: it is left in Err.
New works on a shallow copy of hc whose CheckRedirect refuses to follow a redirect that would carry the token to another host or to plain http (see apiclient.GuardRedirects). kind prefixes that refusal message.
New only reads whether tok is set; the sources keep the Token themselves to resolve it per List call or per page.
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, u string, v netguard.Validators, tok apiclient.Secret, notFound string) (*netguard.Result, error)
Get fetches u with the GitHub headers and, if tok is not empty, a bearer token (never over plain http to a non-loopback host). A 404 is wrapped with notFound followed by " (or not visible to the token)", a 401 with a hint that the token is invalid or expired.