diff options
author | Colin Okay <okay@toyful.space> | 2022-02-08 14:04:29 -0600 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-02-08 14:04:29 -0600 |
commit | 2154ccf238851fe0eff7da33c9792b34d06bbba3 (patch) | |
tree | 1f2ebb02b04141726175828c4d9e143aefe745a4 /lazybones.lisp | |
parent | 721e1bb6e6229c97ad10208df8b90f4fa0d306ba (diff) |
added app-state table
Diffstat (limited to 'lazybones.lisp')
-rw-r--r-- | lazybones.lisp | 15 |
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)))) |