diff options
author | Philip McGrath <philip@philipmcgrath.com> | 2022-05-18 14:10:55 -0400 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-05-22 01:07:52 +0200 |
commit | 9a47fd56dd927995e68a2c894a237aed11aa32f7 (patch) | |
tree | a24da4da654cb6add20ac29171e8b91f211a0ffc /guix/import | |
parent | ae533e3084b726188e78d1519f058e05c8388960 (diff) |
import: json: Accept '#:http-fetch' in 'json-fetch'.
For example, supplying 'http-fetch/cached' would enable caching.
* guix/import/json.scm (json-fetch): Add '#:http-fetch' argument.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/import')
-rw-r--r-- | guix/import/json.scm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/guix/import/json.scm b/guix/import/json.scm index 0c98bb25b8..ae00ee929e 100644 --- a/guix/import/json.scm +++ b/guix/import/json.scm @@ -35,13 +35,16 @@ json->scheme-file)) (define* (json-fetch url + #:key + (http-fetch http-fetch) ;; Note: many websites returns 403 if we omit a ;; 'User-Agent' header. - #:key (headers `((user-agent . "GNU Guile") - (Accept . "application/json")))) + (headers `((user-agent . "GNU Guile") + (Accept . "application/json")))) "Return a representation of the JSON resource URL (a list or hash table), or #f if URL returns 403 or 404. HEADERS is a list of HTTP headers to pass in -the query." +the query. HTTP-FETCH is called to perform the request: for example, to +enable caching, supply 'http-fetch/cached'." (guard (c ((and (http-get-error? c) (let ((error (http-get-error-code c))) (or (= 403 error) |