aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2025-01-13 06:02:16 -0800
committercolin <colin@cicadas.surf>2025-01-13 06:02:16 -0800
commitd1a2f16138c2bee5706668e132077ee3b12a7877 (patch)
tree3759cf5311f80d8f8031324e57898fc1501b73c8
parentdda37d6f9f40d573776ac4bb6abe12adb8f33c47 (diff)
tweaksHEADmain
-rw-r--r--README.org5
-rw-r--r--src/client/ps/generate.lisp13
2 files changed, 13 insertions, 5 deletions
diff --git a/README.org b/README.org
index 2755644..06b2c7c 100644
--- a/README.org
+++ b/README.org
@@ -67,8 +67,9 @@ OOPyness is an advantage. Object orientation allows one to:
endponit classes. Whole regions of a site or API can easly be
extended or modified.
-- You can use the reified endpoints to automatically for your
- API. See the function ~weekend:print-all-route-documentation~.
+- You can use the reified endpoints to automatically generate
+ documentation for your API. See the function
+ ~weekend:print-all-route-documentation~.
- Similarly, you can automatically generate API client code for your
langauge of choice.
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)))))))))))