Documentation
¶
Index ¶
- func BasicHttpRequestReturnStruct(httpMethod string, url string, target interface{}) (int, error)
- func BasicHttpRequestWithNameReturnStruct(httpMethod string, url string, cacheName 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 HttpRequestReturnStructWithName(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
- func BasicHttpRequest(httpMethod string, url string) (Response, error)
- func BasicHttpRequestWithName(httpMethod string, url string, cacheName string) (Response, error)
- func GetCacheAndStaleness(cacheFilename string, cacheTTLOverride time.Duration, allowCacheUpdate bool) (Response, bool, error)
- func HttpRequest(httpMethod string, url string, headers map[string][]string, ...) (Response, error)
- func HttpRequestWithName(httpMethod string, url string, headers map[string][]string, ...) (Response, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicHttpRequestReturnStruct ¶
BasicHttpRequestReturnStruct makes a request with default parameters
func BasicHttpRequestWithNameReturnStruct ¶ added in v1.6.0
func BasicHttpRequestWithNameReturnStruct(httpMethod string, url string, cacheName string, target interface{}) (int, error)
NamedHttpRequestReturnStruct makes a request with a custom cache name and returns the result as a struct
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 HttpRequestReturnStructWithName ¶ added in v1.6.0
func HttpRequestReturnStructWithName(httpMethod string, url string, headers map[string][]string, cacheTTLOverride time.Duration, allowCacheUpdate bool, customCacheName string, target interface{}) (int, error)
HttpRequestReturnStructWithName 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. If customCacheName is provided, it will be used as the cache filename instead of generating a hash from the request.
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 BasicHttpRequestWithName ¶ added in v1.6.0
NamedHttpRequest makes a request with a custom cache name
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.
func HttpRequestWithName ¶ added in v1.6.0
func HttpRequestWithName(httpMethod string, url string, headers map[string][]string, cacheTTLOverride time.Duration, allowCacheUpdate bool, customCacheName string) (Response, error)
HttpRequestWithName 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. If customCacheName is provided, it will be used as the cache filename instead of generating a hash from the request.