summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-03-26 15:57:40 -0500
committerColin Okay <okay@toyful.space>2022-03-26 15:57:40 -0500
commitd248e03474c97d83cd788b38a17fd98ea54464d9 (patch)
tree38084c693a60de5f2173abb753dbf4806a9cd604
parenta4b0884baf23146ebb64389bdb8a829b09e46d09 (diff)
[refactor] making all arguments required
-rw-r--r--lazybones-client.lisp23
1 files changed, 13 insertions, 10 deletions
diff --git a/lazybones-client.lisp b/lazybones-client.lisp
index b17dacc..ccc6ccf 100644
--- a/lazybones-client.lisp
+++ b/lazybones-client.lisp
@@ -43,8 +43,7 @@ endpoint EP."
"Returns a list of strings representing the names of route variables
extracted from endpoint EP, to be used as variable names in the defun
for making requests to that endpoint."
- (mapcar 'symbol-name
- (lazybones::endpoint-route-vars ep)))
+ (lazybones::endpoint-route-vars ep))
(defun endpoint-defun-query-var-names (ep)
"Returns a list of strings representing the names of query parameter
@@ -58,7 +57,7 @@ in the defun for making request to that endpoint."
for making requests to endpoint EP."
(format
nil
- "(%host% %headers% %cookies% ~:[~;%content-type% %body% ~]&key ~{~a ~})"
+ "(%host %headers %cookies ~:[~;%content-type %body ~] ~{~a ~})"
(member (lazybones::endpoint-method ep) '(:post :put :patch))
(append
(endpoint-defun-route-var-names ep)
@@ -84,10 +83,9 @@ for making requests to endpoint EP."
for first = t then nil
for varname in (endpoint-defun-query-var-names ep)
do
- (princ "~:[~;")
(unless first (princ #\&))
(princ (string-upcase varname))
- (princ "=~a~]"))))
+ (princ "=~a"))))
(defun endpoint-defun-dexador-request-uri (app ep)
"Returns a string representation of code that generates a URI for
@@ -104,19 +102,24 @@ for making requests to endpoint EP."
(endpoint-defun-dexador-uri-route-query-format-string ep)
"\" "
(str:join " " (endpoint-defun-route-var-names ep))
- (str:join " " (endpoint-defun-query-var-names ep))))
+ " "
+ (str:join " " (endpoint-defun-query-var-names ep))
+ ")"))
(defun endpoint-defun-body (app ep)
"Returns a string representation of the function body of a defun
for making requests to the endpoint EP in the app APP."
(format
nil
- "(dexador:~a~%~a~%~{~a~%~})"
+ "(dexador:~a~% ~a~%~{ ~a~%~})"
(string-downcase (symbol-name (lazybones::endpoint-method ep)))
(endpoint-defun-dexador-request-uri app ep)
- '(":content %body%"
- ":cookie-jar %cookies%"
- ":headers (append (when %content-type% (list (cons \"Content-Type\" %content-type%))) %headers%)")))
+ (append
+ (when (find (lazybones::endpoint-method ep) '(:patch :put :post))
+ (list ":content %body"))
+ (list
+ ":cookie-jar %cookies"
+ ":headers (append (when %content-type (list (cons \"Content-Type\" %content-type))) %headers)"))))
(defun generate-defun-for-endpoint (app ep)
"Returns a string representation of a defun form for a function that