diff options
author | Colin Okay <okay@toyful.space> | 2022-02-14 10:59:06 -0600 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-02-14 10:59:06 -0600 |
commit | ac62136b092a451c9474c4f7248442910cf42764 (patch) | |
tree | 4d3a60631217dd2bdd17cd5019750e4a7b0603c2 | |
parent | 22a1c72874e579858d6add4f2b617495acc7cd4d (diff) |
lazybones-client.shared; shared symbols for generated clients
-rw-r--r-- | lazybones-client.asd | 2 | ||||
-rw-r--r-- | lazybones-client.lisp | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/lazybones-client.asd b/lazybones-client.asd index 2d59578..316878a 100644 --- a/lazybones-client.asd +++ b/lazybones-client.asd @@ -2,7 +2,7 @@ :description "Generate client functions for a LAZYBONES:APP instance" :author "Colin Okay <okay@toyful.space>" :license "AGPLv3" - :version "0.1.0" + :version "0.1.1" :serial t :depends-on (#:lazybones) :components ((:file "lazybones-client"))) diff --git a/lazybones-client.lisp b/lazybones-client.lisp index 7feb48c..0063987 100644 --- a/lazybones-client.lisp +++ b/lazybones-client.lisp @@ -10,6 +10,9 @@ (defpackage #:dexador (:export #:get #:put #:post #:head #:patch #:delete)) +(defpackage #:lazybones-client.shared + (:export #:*host* #:*body #:*cookies* #:*headers* #:request-with)) + (in-package :lazybones-client) (defparameter +preamble+ @@ -20,7 +23,7 @@ \"Body passed to client post, put, and patch requests\") (defvar *cookies* nil - \"An instance of CL-COOKIE:COOKIE-JAR.\" + \"An instance of CL-COOKIE:COOKIE-JAR.\") (defvar *headers* nil \"A liist of (header-name . header-value) pairs.\") @@ -102,13 +105,13 @@ COOKIES should be an instance of CL-COOKIE:COOKIE-JAR. Defaults to (let ((,req-string (apply #'concatenate 'string - *host* + lazybones-client.shared:*host* (format nil ,format-string ,@vars) (when (or ,@qparams) (list "?" ,@(params-to-query-string qparams)))))) - (if *body* - (,dex-fn ,req-string :content *body* :cookie-jar *cookies* :headers *headers*) - (,dex-fn ,req-string :cookie-jar *cookies* :headers *headers*)))))) + (if lazybones-client.shared:*body* + (,dex-fn ,req-string :content lazybones-client.shared:*body* :cookie-jar lazybones-client.shared:*cookies* :headers lazybones-client.shared:*headers*) + (,dex-fn ,req-string :cookie-jar lazybones-client.shared:*cookies* :headers lazybones-client.shared:*headers*)))))) (defun generate-client-functions-for-app (app) @@ -138,7 +141,9 @@ COOKIES should be an instance of CL-COOKIE:COOKIE-JAR. Defaults to (with-output-to-string (out) (format out - "(defpackage :~a (:use :cl) + " +(defpacakage #:lazybones-client.shared (:export #:*host* #:*body* #:*headers* #:*cookies*)) +(defpackage :~a (:use :cl :lazybones-client.shared) (:export #:*host* #:*body* #:*headers* #:*cookies* #:request-with~% ~{#:~a~^~%~}))" (app-client-package-name app) (all-function-names app)) |