From d1a2f16138c2bee5706668e132077ee3b12a7877 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 13 Jan 2025 06:02:16 -0800 Subject: tweaks --- src/client/ps/generate.lisp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/client/ps') diff --git a/src/client/ps/generate.lisp b/src/client/ps/generate.lisp index 63c7753..0b1b458 100644 --- a/src/client/ps/generate.lisp +++ b/src/client/ps/generate.lisp @@ -10,7 +10,7 @@ ;; this function largely mirrors the implementation of construct-route-builder -(defun generate (class &optional alt-name) +(defun generate (class &key alt-name (content-type "application/json")) (when (symbolp class) (setf class (find-class class))) (let* @@ -53,14 +53,21 @@ method ,(string method) cache "no-cache" ,@(when (wknd:body-expected-p method) - `(headers (ps:create "Content-Type" "application/json"))) + `(headers (ps:create "Content-Type" ,content-type))) redirect "follow" ,@(when body (list 'body body)))) (then (lambda (resp) (and resp (= 200 (ps:@ resp status)) - (ps:chain resp (json))))))))) + ,(cond ((string= content-type "application/json") + `(ps:chain resp (json))) + + ((string= content-type "text/" :end1 5) + `(ps:chain resp (text))) + + (t + `(ps:chain resp (blob))))))))))) -- cgit v1.2.3