(module config mzscheme
(require (file "throttle.ss"))
(define current-username
(make-parameter
#f
(lambda (val)
(if (string? val)
val
(raise (make-exn:fail:contract
(format "Expected string, received ~a." val)
(current-continuation-marks)))))))
(define current-password
(make-parameter
#f
(lambda (val)
(if (string? val)
val
(raise (make-exn:fail:contract
(format "Expected string, received ~a." val)
(current-continuation-marks)))))))
(define current-base-url
(make-parameter
"http://api.del.icio.us:443/v1"
(lambda (val)
(if (string? val)
(if (eq? (string-ref val (sub1 (string-length val))) #\/)
(raise (make-exn:fail:contract
(format "Base URL must not have a trailing slash: ~a." val)
(current-continuation-marks)))
val)
(raise (make-exn:fail:contract
(format "Expected string, received ~a." val)
(current-continuation-marks)))))))
(define current-throttle
(make-parameter
(make-throttle 1000)
(lambda (val)
(if (and (throttle? val) (>= (throttle-delay val) 1000))
val
(raise (make-exn:fail:contract
(format "Expected throttle with a delay >= 1000ms, received ~a" val)
(current-continuation-marks)))))))
(define dump-request-urls?
(make-parameter #f))
(define dump-sxml-responses?
(make-parameter #f))
(provide current-username
current-password
current-base-url
current-throttle
dump-request-urls?
dump-sxml-responses?)
)