diff options
-rw-r--r-- | aws/request.scm | 16 | ||||
-rw-r--r-- | configure.ac | 1 |
2 files changed, 13 insertions, 4 deletions
diff --git a/aws/request.scm b/aws/request.scm index d311ec2..7ccb6c6 100644 --- a/aws/request.scm +++ b/aws/request.scm @@ -26,8 +26,10 @@ #:use-module (gcrypt hmac) #:use-module (rnrs bytevectors) #:use-module (web client) + #:use-module ((web response) #:select (response-content-type)) #:use-module ((web http) #:select (header-writer declare-header!)) #:use-module (sxml simple) + #:use-module (json) #:export (make-operation->request serialize-aws-value)) ;;; Commentary: @@ -264,7 +266,13 @@ (_ "")) #:headers new-headers)) (lambda (response body) - (xml->sxml (match body - ((? bytevector? bv) - (utf8->string bv)) - ((? string? s) s))))))) + (let ((server-text (match body + ((? bytevector? bv) + (utf8->string bv)) + ((? string? s) s)))) + (match (response-content-type response) + (('application/x-amz-json-1.1 . rest) + (json-string->scm server-text)) + (('text/xml . rest) + (xml->sxml server-text)) + (_ server-text))))))) diff --git a/configure.ac b/configure.ac index 0b86834..24ac639 100644 --- a/configure.ac +++ b/configure.ac @@ -11,5 +11,6 @@ AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env]) GUILE_PKG([3.0 2.2]) GUILE_PROGS +GUILE_MODULE_REQUIRED(json) AC_OUTPUT |