aboutsummaryrefslogtreecommitdiff
path: root/lazybones.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lazybones.lisp')
-rw-r--r--lazybones.lisp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lazybones.lisp b/lazybones.lisp
index db1ca2a..3597c0e 100644
--- a/lazybones.lisp
+++ b/lazybones.lisp
@@ -18,6 +18,10 @@
"Dynamic variable holding the an APP instance. Dynamically bound by
RUN-ENDPOINT so that it is available if needed in request handlers.")
+;;; APP NAMESPACE
+
+(lisp-namespace:define-namespace lazybones)
+
;;; LAZYBONES CLASSES
(defclass app ()
@@ -35,6 +39,12 @@
:accessor app-endpoints
:initform nil)))
+(defmethod initialize-instance :after ((app app) &key)
+ (setf (symbol-lazybones (app-name app)) app))
+
+(defun app (name)
+ (symbol-lazybones name nil))
+
(defclass endpoint ()
((method
:reader endpoint-method
@@ -167,7 +177,16 @@ Returns NIL on failure."
(defun run-endpoint (endpoint args request response app)
+ "Bind dynamic variables *request* *response* and *app* before
+applying HANDLER-FUNCTION slot of ENDPOINT to the ARGS list."
(let ((*request* request)
(*response* response)
(*app* app))
(apply (endpoint-request-handler endpoint) args)))
+
+;;; ENDPOINT DEFINITION
+
+(defmacro defendpoint (appname method route-template (&key (auth nil)) &body body)
+ "Defines and installs an ENDPOINT instance to the APP instance
+indicated by APPNAME, first checking an APP called APPNAME exits,
+making a new one if not." )