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 | |
parent | 721e1bb6e6229c97ad10208df8b90f4fa0d306ba (diff) |
added app-state table
-rw-r--r-- | lazybones.lisp | 15 | ||||
-rw-r--r-- | package.lisp | 1 |
2 files changed, 13 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)))) diff --git a/package.lisp b/package.lisp index 826ad8a..a2bcfac 100644 --- a/package.lisp +++ b/package.lisp @@ -42,6 +42,7 @@ #:generate-app-documentation #:provision-app #:app + #:app-state #:create-server #:defendpoint #:defendpoint* |