Documentation
¶
Overview ¶
Package online for remote interactions.
Index ¶
Examples ¶
Constants ¶
View Source
const ( // ReleaseAPI GitHub API v3 releases endpoint. // See: https://developer.github.com/v3/repos/releases/ ReleaseAPI = "https://api.github.com/repos/bengarrett/retrotxtgo/releases/latest" )
Variables ¶
View Source
var ( ErrJSON = errors.New("cannot understand the response body as the syntax is not json") ErrMash = errors.New("cannot unmarshal the json response body") )
Functions ¶
func Get ¶
Get fetches a URL and returns both its response and body. If an etag is provided a "If-None-Match" header request will be included.
Example ¶
_, d, _ := Get("https://demozoo.org/api/v1/productions/126496/", "") _, g, _ := Get(ReleaseAPI, "") fmt.Println("valid json api?", json.Valid(d)) fmt.Println("valid github api?", json.Valid(g))
Output: valid json api? true valid github api? true
Types ¶
type API ¶
type API map[string]interface{}
API interface to store the JSON results from GitHub.
func Endpoint ¶
Endpoint request an API endpoint from the URL. A HTTP ETag can be provided to validate local data cache against the server. The useCache will return true with the etag value matches the server's ETag header.
Example ¶
_, p, _ := Endpoint("https://demozoo.org/api/v1/productions/126496/", `W/"0708012ac3fb439a46dd5156195901b4"`) fmt.Println("id:", p["id"])
Output: id: 126496
Click to show internal directories.
Click to hide internal directories.