From 97c0ad9e99d4d56e8ee15cd2ef83ecd7dd82ebf8 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sat, 26 Mar 2022 16:22:08 -0500 Subject: [bugfix] gets don't need a content-type header --- lazybones-client.lisp | 23 ++++++++++++++--------- 1 file 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) -- cgit v1.2.3