github

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: MIT Imports: 11 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"
View Source
const VERSION = "0.10.1-mist1"

Variables

View Source
var VERBOSITY = 0

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

Functions

func DoAuthRequest

func DoAuthRequest(method, url, mime, token 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 GetFileSize

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

Types

type Client

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

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 NewClient added in v0.8.0

func NewClient(username, token string, client *restclient.Client) Client

NewClient creates a new Client for use with the Github API.

func (Client) Do added in v0.9.0

func (c Client) Do(r *http.Request) (*http.Response, error)

Caller is responsible for reading and closing the response body.

func (Client) Get

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

func (Client) GetPaginated added in v0.9.1

func (c Client) GetPaginated(uri string, limit int, v interface{}) (string, error)

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

func (Client) NewRequest added in v0.8.0

func (c Client) NewRequest(method, uri string, body io.Reader) (*http.Request, error)

func (Client) SetBaseURL added in v0.8.0

func (c Client) SetBaseURL(baseurl string)

SetBaseURL updates the client's base URL, if baseurl is a non-empty value.

Jump to

Keyboard shortcuts

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