summaryrefslogtreecommitdiff
path: root/src/scm/webid-oidc/client/application.scm
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-09-22 13:11:21 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-09-22 18:08:47 +0200
commit555e59deba33284067298ce6130c379c75e3d2a3 (patch)
treec15c823913e917bc474f1cf163caf65a117ee9c3 /src/scm/webid-oidc/client/application.scm
parent0d74f8c1ca9c1e9bf9a04b85f598ba7a175d1d86 (diff)
Use anonymous-http-request from (webid-oidc parameters) everywhere
Diffstat (limited to 'src/scm/webid-oidc/client/application.scm')
-rw-r--r--src/scm/webid-oidc/client/application.scm55
1 files changed, 20 insertions, 35 deletions
diff --git a/src/scm/webid-oidc/client/application.scm b/src/scm/webid-oidc/client/application.scm
index 5839195..d448976 100644
--- a/src/scm/webid-oidc/client/application.scm
+++ b/src/scm/webid-oidc/client/application.scm
@@ -39,7 +39,6 @@
#:use-module (webid-oidc web-i18n)
#:use-module (web uri)
#:use-module (web response)
- #:use-module (web client)
#:use-module (rnrs bytevectors)
#:use-module (oop goops)
#:declarative? #t
@@ -155,21 +154,6 @@
((hd tl ...)
(apply-finished-jobs (hd state) tl)))))))
-(define http-request-with-cache
- (let ((default-http-get-with-cache (cache:with-cache)))
- (lambda* (uri . all-args)
- (let try-get-with-cache ((args all-args)
- (args-for-get '()))
- (match args
- (()
- (apply default-http-get-with-cache uri (reverse args-for-get)))
- ((#:headers arg other-args ...)
- (try-get-with-cache other-args `(,arg #:headers ,@args-for-get)))
- ((#:method 'GET other-args ...)
- (try-get-with-cache other-args args-for-get))
- (else
- (apply http-request uri all-args)))))))
-
(define-method (add-job (state <application-state>) (description <string>) f)
(let ((job (make <job> #:description description)))
(call-with-new-thread
@@ -197,25 +181,26 @@
(slot-set! ret 'authorization-prompts
`((,uri . ,continue)
,@(authorization-prompts previous-state)))
- ret))))))
- (account:anonymous-http-request http-request-with-cache))
- (with-exception-handler
- (lambda (exn)
- (let ((msg (if (exception-with-message? exn)
- (exception-message exn)
- (format #f "~s" exn))))
- (abort-to-prompt
- tag
- (lambda (_)
- ;; We won’t continue, but we will show the error message
- (lambda (previous-state)
- (let ((ret (shallow-clone previous-state)))
- (slot-set! ret 'error-messages
- `(,msg ,@(error-messages previous-state)))
- ret))))))
- (lambda ()
- (let ((updater (f)))
- (atomic-box-set! (result-box job) updater))))))
+ ret)))))))
+ (cache:use-cache
+ (lambda ()
+ (with-exception-handler
+ (lambda (exn)
+ (let ((msg (if (exception-with-message? exn)
+ (exception-message exn)
+ (format #f "~s" exn))))
+ (abort-to-prompt
+ tag
+ (lambda (_)
+ ;; We won’t continue, but we will show the error message
+ (lambda (previous-state)
+ (let ((ret (shallow-clone previous-state)))
+ (slot-set! ret 'error-messages
+ `(,msg ,@(error-messages previous-state)))
+ ret))))))
+ (lambda ()
+ (let ((updater (f)))
+ (atomic-box-set! (result-box job) updater))))))))
(lambda (continuation get-updater)
(atomic-box-set! (result-box job) (get-updater continuation)))))))
(let ((ret (shallow-clone state)))