ghapi

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func ParseRepo

func ParseRepo(kind string, t source.Target) (owner, name string, err error)

ParseRepo checks that t is of the given kind and splits its "repo" coordinate into owner and name.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client sends GitHub API requests.

func New

func New(kind, baseURL string, hc *http.Client, tok apiclient.Token) *Client

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

func (c *Client) Base() string

Base is the API base URL without a trailing slash.

func (*Client) Err

func (c *Client) Err() error

Err is an invalid configuration, to be reported by the source's List.

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.

Jump to

Keyboard shortcuts

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