summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-03-26 16:22:08 -0500
committerColin Okay <okay@toyful.space>2022-03-26 16:22:08 -0500
commit97c0ad9e99d4d56e8ee15cd2ef83ecd7dd82ebf8 (patch)
treed09683286bdfbebb632e199c80aaa5735aff902f
parent3f53200ad8fb9bb68cd4f971867289595b05fb11 (diff)
[bugfix] gets don't need a content-type header
-rw-r--r--lazybones-client.lisp23
1 files changed, 14 insertions, 9 deletions
diff --git a/lazybones-client.lisp b/lazybones-client.lisp
index 9f10041..65baed4 100644
--- a/lazybones-client.lisp
+++ b/lazybones-client.lisp
@@ -52,16 +52,20 @@ in the defun for making request to that endpoint."
(mapcar (a:compose #'symbol-name #'first)
(lazybones::endpoint-params ep)))
+
+(defun endpoint-accepts-body-p (ep)
+ (member (lazybones::endpoint-method ep) '(:post :put :patch)) )
+
(defun endpoint-defun-lambda-list (ep)
"Returns a string representation of the lambda list of the defun
for making requests to endpoint EP."
(format
nil
- "(%host %headers %cookies ~:[~;%content-type %body ~] ~{~a ~})"
- (member (lazybones::endpoint-method ep) '(:post :put :patch))
+ "(~{~a ~} %host ~:[~;%content-type %body ~] &optional %headers %cookies)"
(append
(endpoint-defun-route-var-names ep)
- (endpoint-defun-query-var-names ep))))
+ (endpoint-defun-query-var-names ep))
+ (endpoint-accepts-body-p ep)))
(defun endpoint-defun-dexador-uri-route-format-string (ep)
@@ -116,17 +120,18 @@ for making requests to endpoint EP."
(string-downcase (symbol-name (lazybones::endpoint-method ep)))
(endpoint-defun-dexador-request-uri app ep)
(append
- (when (find (lazybones::endpoint-method ep) '(:patch :put :post))
- (list ":content %body"))
- (list
- ":cookie-jar %cookies"
- ":headers (cons (cons \"Content-Type\" %content-type) %headers)"))))
+ (if (endpoint-accepts-body-p ep)
+ (list ":content %body"
+ ":cookie-jar %cookies"
+ ":headers (cons (cons \"Content-Type\" %content-type) %headers)")
+ (list ":cookie-jar %cookies"
+ ":headers %headers")))))
(defun generate-defun-for-endpoint (app ep)
"Returns a string representation of a defun form for a function that
makes a request to the endpoint EP."
(format nil
- "(defun ~a ~a~% ~s~%~a)"
+ "(defun ~a~% ~a~% ~s~%~a)"
(endpoint-defun-name ep)
(endpoint-defun-lambda-list ep)
(lazybones::endpoint-documentation ep)