api

package
v3.0.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2018 License: MIT Imports: 9 Imported by: 60

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// UserAgent lets the API know where the call is being made from.
	// It's overridden from the root command so that we can set the version.
	UserAgent = "github.com/exercism/cli"

	// TimeoutInSeconds is the timeout the default HTTP client will use.
	TimeoutInSeconds = 60
	// HTTPClient is the client used to make HTTP calls in the cli package.
	HTTPClient = &http.Client{Timeout: time.Duration(TimeoutInSeconds) * time.Second}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client
	ContentType string
	Token       string
	APIBaseURL  string
}

Client is an http client that is configured for Exercism.

func NewClient

func NewClient(token, baseURL string) (*Client, error)

NewClient returns an Exercism API client.

func (*Client) Do

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

Do performs an http.Request and optionally parses the response body into the given interface.

func (*Client) IsPingable

func (c *Client) IsPingable() error

IsPingable calls the API /ping to determine whether the API can be reached.

func (*Client) NewRequest

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

NewRequest returns an http.Request with information for the Exercism API.

func (*Client) TokenIsValid

func (c *Client) TokenIsValid() (bool, error)

TokenIsValid calls the API to determine whether the token is valid.

Jump to

Keyboard shortcuts

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