Documentation ¶
Index ¶
- func BasicHttpRequestReturnStruct(httpMethod string, url string, target interface{}) (int, error)
- func GetCacheAndStalenessReturnStruct(cacheFilename string, cacheTTLOverride time.Duration, allowCacheUpdate bool, ...) (bool, error)
- func GetCacheFileAsString(filename string) (string, error)
- func GetCacheFileAsStruct(filename string, target interface{}) error
- func HttpRequestReturnStruct(httpMethod string, url string, headers map[string][]string, ...) (int, error)
- func WriteStringToCacheFile(filename string, value string) error
- func WriteStructToCacheFile(filename string, rawStruct interface{}) error
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicHttpRequestReturnStruct ¶
BasicHttpRequestReturnStruct makes a request with default parameters
func GetCacheAndStalenessReturnStruct ¶ added in v1.1.0
func GetCacheAndStalenessReturnStruct(cacheFilename string, cacheTTLOverride time.Duration, allowCacheUpdate bool, target interface{}) (bool, error)
GetCacheAndStalenessReturnStruct is the same as GetCacheAndStaleness but it returns the result as a specified struct. GetCacheAndStalenessReturnStruct returns the contents of the cache file as a struct and whether or not the cache is stale (this does not make an HTTP request)
func GetCacheFileAsString ¶ added in v1.4.1
GetCacheFileAsString reads the content of a file and returns it as a string.
func GetCacheFileAsStruct ¶ added in v1.2.0
GetCacheFileAsStruct reads the content of a file, unmarshals it as JSON into the target structure.
func HttpRequestReturnStruct ¶
func HttpRequestReturnStruct(httpMethod string, url string, headers map[string][]string, cacheTTLOverride time.Duration, allowCacheUpdate bool, target interface{}) (int, error)
HttpRequestReturnStruct is the same as HttpRequest but it returns the result as a specified struct. HttpRequest sends an HTTP request to the specified URL and returns the HTTP response. The response is cached for a duration specified by cacheTTL. If cacheTTLOverride is zero, the default cache TTL value is used.
func WriteStringToCacheFile ¶ added in v1.1.0
func WriteStructToCacheFile ¶ added in v1.1.0
Types ¶
type Response ¶
func BasicHttpRequest ¶
BasicHttpRequest makes a request with default parameters
func GetCacheAndStaleness ¶ added in v1.1.0
func GetCacheAndStaleness(cacheFilename string, cacheTTLOverride time.Duration, allowCacheUpdate bool) (Response, bool, error)
GetCacheAndStaleness returns the contents of the cache file and whether or not the cache is stale (this does not make an HTTP request)
func HttpRequest ¶
func HttpRequest(httpMethod string, url string, headers map[string][]string, cacheTTLOverride time.Duration, allowCacheUpdate bool) (Response, error)
HttpRequest sends an HTTP request to the specified URL and returns the HTTP response. The response is cached for a duration specified by cacheTTL. If cacheTTLOverride is zero, the default cache TTL value is used.