aboutsummaryrefslogtreecommitdiff
path: root/lazybones.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lazybones.lisp')
-rw-r--r--lazybones.lisp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lazybones.lisp b/lazybones.lisp
index cf438cf..0ac07ba 100644
--- a/lazybones.lisp
+++ b/lazybones.lisp
@@ -60,6 +60,10 @@
is evoked when an ENDPOINT's AUTH slot is T. Endpoints may
override this behavor by supplying a function in place of T. A
value of NIL means that there is no default authorizer.")
+ (state-table
+ :accessor app-state-table
+ :initform (make-hash-table)
+ :documentation "A hash table with EQL comparing keys. Used for storing arbitrary application state.")
(app-error-response-contents
:accessor app-error-response-contents
:initform nil
@@ -73,6 +77,12 @@
:accessor app-endpoints
:initform nil)))
+(defun app-state (key &optional (app *app*))
+ (gethash key (app-state-table app)))
+
+(defun (setf app-state) (value key &optional (app *app*))
+ (setf (gethash key (app-state-table app)) value))
+
(defun error-content (code &optional (app *app*))
(cdr (assoc code (app-error-response-contents app))))
@@ -391,7 +401,6 @@ file. CONTENT-TYPE should be a MIME type string."
"*APP*, *RESPONSE* and *REQUEST* should all be defined here."
(http-respond
code
- (or content (default-error-response code))))
+ (or content (error-content code))))
+
-(defun default-error-response (code &optional (app *app*))
- (cdr (assoc code (app-error-response-contents app))))