github

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package github is a mini-library for querying the GitHub v3 API that takes care of authentication (with tokens only) and pagination.

Index

Constants

View Source
const DefaultBaseURL = "https://api.github.com"

Variables

View Source
var VERBOSITY = 0

Set to values > 0 to control verbosity, for debugging.

Functions

func GetFileSize

func GetFileSize(f *os.File) (int64, error)

Types

type Client

type Client struct {
	// AuthUser is the GitHub user which is authenticating.
	AuthUser string
	// Token is the GitHub API token, used when set.
	Token string
	// BaseURL is the GitHub API URL, defaults to DefaultBaseURL if unset.
	BaseURL string
}

Client collects a few options that can be set when contacting the GitHub API, such as authorization tokens. Methods called on Client will supply these options when calling the API.

func (*Client) DoAuthRequest added in v0.8.0

func (c *Client) DoAuthRequest(method, url, mime string, headers map[string]string, body io.Reader) (*http.Response, error)

DoAuthRequest ...

TODO: This function is amazingly ugly (separate headers, token, no API URL constructions, et cetera).

func (*Client) Get

func (c *Client) Get(uri string, v interface{}) error

Get fetches uri (relative URL) from the GitHub API and unmarshals the response into v. It takes care of pagination transparantly.

Jump to

Keyboard shortcuts

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