Documentation ¶
Index ¶
- func GetReadWriter(i interface{}) (io.ReadWriter, error)
- type AppsTransport
- func NewAppsTransport(tr http.RoundTripper, appID int64, privateKey []byte) (*AppsTransport, error)
- func NewAppsTransportFromPrivateKey(tr http.RoundTripper, appID int64, key *rsa.PrivateKey) *AppsTransport
- func NewAppsTransportKeyFromFile(tr http.RoundTripper, appID int64, privateKeyFile string) (*AppsTransport, error)
- type Client
- type HTTPError
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetReadWriter ¶
func GetReadWriter(i interface{}) (io.ReadWriter, error)
GetReadWriter converts a body interface into an io.ReadWriter object.
Types ¶
type AppsTransport ¶
type AppsTransport struct { BaseURL string // BaseURL is the scheme and host for GitHub API, defaults to https://api.github.com Client Client // Client to use to refresh tokens, defaults to http.Client with provided transport // contains filtered or unexported fields }
AppsTransport provides a http.RoundTripper by wrapping an existing http.RoundTripper and provides GitHub Apps authentication as a GitHub App.
Client can also be overwritten, and is useful to change to one which provides retry logic if you do experience retryable errors.
func NewAppsTransport ¶
func NewAppsTransport(tr http.RoundTripper, appID int64, privateKey []byte) (*AppsTransport, error)
NewAppsTransport returns a AppsTransport using private key. The key is parsed and if any errors occur the error is non-nil.
The provided tr http.RoundTripper should be shared between multiple installations to ensure reuse of underlying TCP connections.
The returned Transport's RoundTrip method is safe to be used concurrently.
func NewAppsTransportFromPrivateKey ¶
func NewAppsTransportFromPrivateKey(tr http.RoundTripper, appID int64, key *rsa.PrivateKey) *AppsTransport
NewAppsTransportFromPrivateKey returns an AppsTransport using a crypto/rsa.(*PrivateKey).
func NewAppsTransportKeyFromFile ¶
func NewAppsTransportKeyFromFile(tr http.RoundTripper, appID int64, privateKeyFile string) (*AppsTransport, error)
NewAppsTransportKeyFromFile returns a AppsTransport using a private key from file.
type Client ¶
Client is a HTTP client which sends a http.Request and returns a http.Response or an error.
type HTTPError ¶
type HTTPError struct { Message string RootCause error InstallationID int64 Response *http.Response }
HTTPError represents a custom error for failing HTTP operations. Example in our usecase: refresh access token operation. It enables the caller to inspect the root cause and response.
type Transport ¶
type Transport struct { BaseURL string // BaseURL is the scheme and host for GitHub API, defaults to https://api.github.com Client Client // Client to use to refresh tokens, defaults to http.Client with provided transport InstallationTokenOptions *github.InstallationTokenOptions // parameters restrict a token's access // contains filtered or unexported fields }
Transport provides a http.RoundTripper by wrapping an existing http.RoundTripper and provides GitHub Apps authentication as an installation.
Client can also be overwritten, and is useful to change to one which provides retry logic if you do experience retryable errors.
func New ¶
New returns an Transport using private key. The key is parsed and if any errors occur the error is non-nil.
The provided tr http.RoundTripper should be shared between multiple installations to ensure reuse of underlying TCP connections.
The returned Transport's RoundTrip method is safe to be used concurrently.
func NewFromAppsTransport ¶
func NewFromAppsTransport(atr *AppsTransport, installationID int64) *Transport
NewFromAppsTransport returns a Transport using an existing *AppsTransport.
func NewKeyFromFile ¶
func NewKeyFromFile(tr http.RoundTripper, appID, installationID int64, privateKeyFile string) (*Transport, error)
NewKeyFromFile returns a Transport using a private key from file.
func (*Transport) Permissions ¶
func (t *Transport) Permissions() (github.InstallationPermissions, error)
Permissions returns a transport token's GitHub installation permissions.
func (*Transport) Repositories ¶
func (t *Transport) Repositories() ([]github.Repository, error)
Repositories returns a transport token's GitHub repositories.