aboutsummaryrefslogtreecommitdiff
path: root/lazybones.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lazybones.lisp')
-rw-r--r--lazybones.lisp33
1 files changed, 26 insertions, 7 deletions
diff --git a/lazybones.lisp b/lazybones.lisp
index 45da60b..8e1228b 100644
--- a/lazybones.lisp
+++ b/lazybones.lisp
@@ -30,6 +30,18 @@
:initarg :name
:initform (error "Appname is required")
:type symbol)
+ (title
+ :accessor app-title
+ :initarg :title
+ :initform ""
+ :type string
+ :documentation "A string title")
+ (description
+ :accessor app-description
+ :initarg :description
+ :initform ""
+ :type string
+ :documentation "A string describing the app")
(version
:reader app-version
:initarg :vsn :initarg :version
@@ -65,8 +77,13 @@
(defmethod initialize-instance :after ((app app) &key)
(setf (symbol-lazybones (app-name app)) app))
-(defun app (name)
- (symbol-lazybones name nil))
+(defun app (&optional name)
+ "Get the APP instance named by the symbol NAME. If NAME is not
+supplied, get the default app. Every package has at most one default
+app, named with the package name."
+ (symbol-lazybones (or name
+ (intern (package-name *package*) *package*))
+ nil))
(defclass endpoint ()
((method
@@ -237,8 +254,9 @@ applying HANDLER-FUNCTION slot of ENDPOINT to the ARGS list."
(let ((*request* request)
(*response* response)
(*app* app))
- (when (request-authorized-p endpoint)
- (apply (endpoint-request-handler endpoint) args))))
+ (if (request-authorized-p endpoint)
+ (apply (endpoint-request-handler endpoint) args)
+ (http-err 404))))
(defun request-authorized-p (endpoint)
"Attempts to authorize an endpoint.
@@ -254,9 +272,10 @@ authorizer is used.
Hence, if the endpoint authorizer is T and the app doesn't have an
authorizer, then, the endpoint wants to be authorized but there isn't
any way to do it, hence NIL is returned."
- (a:if-let (specific-authorizer (request-authorizer endpoint))
- (if (functionp specific-authorizer)
- (funcall specific-authorizer)
+ (a:if-let (auth (request-authorizer endpoint))
+ (if (or (functionp auth)
+ (and (symbolp auth) (fboundp auth)))
+ (funcall auth)
(when (request-authorizer *app*) ; perhaps this should be an if, and
(funcall (request-authorizer *app*))))
t))