aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-06 08:31:50 -0600
committerColin Okay <okay@toyful.space>2022-02-06 08:31:50 -0600
commitf4516bd373812b81261c3018c39de7b6fe141d6b (patch)
tree2d716f8ffaf85f16033b7fa3f7ad1c64f9ce3003
parentb3e6b285bb39df9855f36be49f2fc416623c8414 (diff)
binding of dynamic variables pushed to run-endpoint
-rw-r--r--lazybones-hunchentoot.lisp14
-rw-r--r--lazybones.lisp10
2 files changed, 14 insertions, 10 deletions
diff --git a/lazybones-hunchentoot.lisp b/lazybones-hunchentoot.lisp
index 2b84ac1..1e62b85 100644
--- a/lazybones-hunchentoot.lisp
+++ b/lazybones-hunchentoot.lisp
@@ -122,11 +122,9 @@ the value of the Content-Type request header."
:address "0.0.0.0"))
(defmethod h:acceptor-dispatch-request ((acceptor lazybones-acceptor) request)
- (let ((lzb:*request* request)
- (lzb:*response* h:*reply*))
- (loop for app in (acceptor-apps acceptor)
- for (endpoint . args) = (lzb:find-endpoint app request)
- when endpoint
- return (lzb:run-endpoint endpoint args request)
- ;; if no endpoint was found, call next method.
- finally (call-next-method))))
+ (loop for app in (acceptor-apps acceptor)
+ for (endpoint . args) = (lzb:find-endpoint app request)
+ when endpoint
+ return (lzb:run-endpoint endpoint args request h:*reply* app)
+ ;; if no endpoint was found, call next method.
+ finally (call-next-method)))
diff --git a/lazybones.lisp b/lazybones.lisp
index 593328e..db1ca2a 100644
--- a/lazybones.lisp
+++ b/lazybones.lisp
@@ -14,6 +14,10 @@
bound and available to each handler. The exact object bound
*response* varies according to the current backend. ")
+(defvar *app* nil
+ "Dynamic variable holding the an APP instance. Dynamically bound by
+ RUN-ENDPOINT so that it is available if needed in request handlers.")
+
;;; LAZYBONES CLASSES
(defclass app ()
@@ -162,6 +166,8 @@ Returns NIL on failure."
(list (gensym var-name))))))
-(defun run-endpoint (endpoint args &optional (request *request*))
- (let ((*request* request))
+(defun run-endpoint (endpoint args request response app)
+ (let ((*request* request)
+ (*response* response)
+ (*app* app))
(apply (endpoint-request-handler endpoint) args)))