diff options
author | Colin Okay <okay@toyful.space> | 2022-02-06 09:05:02 -0600 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-02-06 09:05:02 -0600 |
commit | f89ad7bd1513536977fc093ad4390ece85b341b8 (patch) | |
tree | 239dbcd9a46fbe0258eae3a868ad6ca42f4531cd | |
parent | 8debc67c73f29a1c3ec4627e39161100568ab8c8 (diff) |
defined lazybones namespace for holding app instances
-rw-r--r-- | clpmfile.lock | 6 | ||||
-rw-r--r-- | lazybones.asd | 3 | ||||
-rw-r--r-- | lazybones.lisp | 19 |
3 files changed, 27 insertions, 1 deletions
diff --git a/clpmfile.lock b/clpmfile.lock index 650a906..874567c 100644 --- a/clpmfile.lock +++ b/clpmfile.lock @@ -58,6 +58,8 @@ ("lazybones-hunchentoot.asd" :version :newest :source :implicit-file :systems ("lazybones-hunchentoot")) ("lazybones.asd" :version :newest :source :implicit-file :systems ("lazybones")) +("lisp-namespace" :version "2021-10-21" :source "quicklisp" :systems + ("lisp-namespace")) ("md5" :version "2021-06-30" :source "quicklisp" :systems ("md5")) ("named-readtables" :version "2021-12-09" :source "quicklisp" :systems ("named-readtables")) @@ -87,6 +89,7 @@ :reverse-dependencies ("alexandria" ((:system :name "static-vectors") (:system :name "alexandria")) ((:system :name "proc-parse") (:system :name "alexandria")) + ((:system :name "lisp-namespace") (:system :name "alexandria")) ((:system :name "lazybones") (:system :name "alexandria")) ((:system :name "hunchentoot") (:system :name "alexandria")) ((:system :name "fast-io") (:system :name "alexandria")) @@ -164,6 +167,9 @@ ((:system :name "lazybones-hunchentoot") (:system :name "lazybones")) (t (:asd-file :name "lazybones.asd"))) +("lisp-namespace" + ((:system :name "lazybones") (:system :name "lisp-namespace"))) + ("md5" ((:system :name "hunchentoot") (:system :name "md5"))) ("named-readtables" diff --git a/lazybones.asd b/lazybones.asd index a0ee531..3a1326c 100644 --- a/lazybones.asd +++ b/lazybones.asd @@ -10,7 +10,8 @@ #:str #:cl-ppcre #:closer-mop - #:jonathan) + #:jonathan + #:lisp-namespace) :components ((:file "package") (:file "lazybones"))) 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." ) |