Documentation
¶
Index ¶
Constants ¶
const ( // Addr is the server address Addr string = "localhost:12345" )
Variables ¶
This section is empty.
Functions ¶
func GetFromURLOrDefaultCache ¶
GetFromURLOrDefaultCache downloads file into cacheDir and returns its content
If the URL is not available, attempt to read the previous response from cache ¶
The function only returns remote error if both downloading from the URL and reading from existing cache fail, cache-related error is only logged, not reported.
func GetFromURLOrDefaultCacheWithCallback ¶
func GetFromURLOrDefaultCacheWithCallback(req *http.Request, cacheDir string, onData func([]byte) error) error
GetFromURLOrDefaultCacheWithCallback downloads file into cacheDir and passes the content to the onData callback
If the URL is not available, attempt to read the previous response from cache ¶
The onData function should process the data (e.g. parsing JSON) and return error on failure. It may be called a second time to process cache if the data from remote URL cannot be processed.
The function only returns remote error if both downloading from the URL and reading from existing cache fail, cache-related error is only logged, not reported.
func StartHTTPServer ¶
func StartHTTPServer(testFilePath string) func()
StartHTTPServer starts a HTTP server in background.
Returns a function that closes the server and the listener completely
Types ¶
This section is empty.