api

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleHTTPError

func HandleHTTPError(resp *http.Response) error

func NewHTTPClient

func NewHTTPClient(opts ...ClientOption) *http.Client

NewHTTPClient initializes an http.Client

Types

type Client

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

Client facilitates making HTTP requests to the GitHub API

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient initializes a Client

func NewClientFromHTTP

func NewClientFromHTTP(httpClient *http.Client) *Client

NewClientFromHTTP takes in an http.Client instance

func (Client) GraphQL

func (c Client) GraphQL(hostname string, query string, variables map[string]interface{}, data interface{}) error

GraphQL performs a GraphQL request and parses the response

func (Client) HasMinimumScopes

func (c Client) HasMinimumScopes(hostname string) error

func (Client) REST

func (c Client) REST(hostname string, method string, p string, body io.Reader, data interface{}) error

REST performs a REST request and parses the response.

type ClientOption

type ClientOption = func(http.RoundTripper) http.RoundTripper

ClientOption represents an argument to NewClient

func AddHeader

func AddHeader(name, value string) ClientOption

AddHeader turns a RoundTripper into one that adds a request header

func AddHeaderFunc

func AddHeaderFunc(name string, getValue func(*http.Request) (string, error)) ClientOption

AddHeaderFunc is an AddHeader that gets the string value from a function

func ReplaceTripper

func ReplaceTripper(tr http.RoundTripper) ClientOption

ReplaceTripper substitutes the underlying RoundTripper with a custom one

func VerboseLog

func VerboseLog(out io.Writer, logTraffic bool, colorize bool) ClientOption

VerboseLog enables request/response logging within a RoundTripper

type GraphQLError

type GraphQLError struct {
	Type    string
	Path    []string
	Message string
}

GraphQLError is a single error returned in a GraphQL response

type GraphQLErrorResponse

type GraphQLErrorResponse struct {
	Errors []GraphQLError
}

GraphQLErrorResponse contains errors returned in a GraphQL response

func (GraphQLErrorResponse) Error

func (gr GraphQLErrorResponse) Error() string

type HTTPError

type HTTPError struct {
	StatusCode  int
	RequestURL  *url.URL
	Message     string
	OAuthScopes string
}

HTTPError is an error returned by a failed API call

func (HTTPError) Error

func (err HTTPError) Error() string

type MissingScopesError

type MissingScopesError struct {
	MissingScopes []string
}

func (MissingScopesError) Error

func (e MissingScopesError) Error() string

Jump to

Keyboard shortcuts

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