Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultAPIHostname = "api.github.com"
Variables ¶
View Source
var DefaultEnvTokenReader = EnvTokenReader{
VarName: "GITHUB_TOKEN",
}
DefaultEnvTokenReader is an env token reader configured to read the token from the GITHUB_TOKEN env variable.
Functions ¶
func WithCaller ¶
func WithCaller(c Caller) fnOpt
func WithEnsureToken ¶
func WithEnsureToken(e bool) fnOpt
func WithTokenReader ¶
func WithTokenReader(r TokenReader) fnOpt
Types ¶
type Caller ¶
type Caller interface {
RequestWithContext(context.Context, string, string, io.Reader) (*http.Response, error)
}
Replaceable caller interface
type Client ¶
type Client struct {
Options Options
// contains filtered or unexported fields
}
func NewClientWithOptions ¶
NewClientWithOptions creates a new client, taking a full options set.
type EnvTokenReader ¶
type EnvTokenReader struct {
VarName string
}
EnvTokenReader is a token reader that extracts an API token from an environment variable
func (*EnvTokenReader) ReadToken ¶
func (etr *EnvTokenReader) ReadToken() (string, error)
ReadToken reads the token string from the convigured `VarName` environment variable.
type FileCaller ¶
FileCaller implements the Caller but returns the data as read from a file specified in SourcePath. This is intended mostly for testing.
type Options ¶
type Options struct {
Host string
Token string
EnsureToken bool
TokenReader TokenReader
Caller Caller
}
type TokenReader ¶
TokenReader is an interface that abstracts a mechanism to read a token securely.
Click to show internal directories.
Click to hide internal directories.