From f89ad7bd1513536977fc093ad4390ece85b341b8 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 6 Feb 2022 09:05:02 -0600 Subject: defined lazybones namespace for holding app instances --- lazybones.lisp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lazybones.lisp') 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." ) -- cgit v1.2.3