This is a slight rework of the way weblocks handles default application. Motivations for the change are as follows:
1. Hunchentoot 1.2 does not support *DEFAULT-HANDLER* - needs the update 2. There's a need in production to have a different default application than weblocks' standard. Hence the variable *WEBLOCKS- DEFAULT-APP-NAME*. Set it to the symbol naming your weblocks app to make it default. 3. It might be necessary to make default application depend on the situation (for example the name of the virtual host to which the request is made). So there's a variable *WEBLOCKS-DEFAULT-APP-NAME- FN*, that can be set to a function taking request object and returning symbol naming an application. I'm also posting these changes with some other bugfixes and updates for Hunchentoot 1.2 in my clone of weblocks here: https://github.com/ury-marshak/weblocks-dev/tree/updates and here is the diff (for this change): diff --git a/src/acceptor.lisp b/src/acceptor.lisp index 347222d..9f96940 100644 --- a/src/acceptor.lisp +++ b/src/acceptor.lisp @@ -1,7 +1,7 @@ (in-package :weblocks) -(export '(weblocks-acceptor)) +(export '(weblocks-acceptor *weblocks-default-app-name* *weblocks- default-app-name-fn*)) (defclass weblocks-acceptor (#.(if (find-class 'easy-acceptor nil) 'easy-acceptor @@ -22,3 +22,25 @@ (let ((*print-readably* nil)) (call-next-method))) +(defvar *weblocks-default-app-name* 'weblocks-default) + +(defvar *weblocks-default-app-name-fn* (lambda (request) + (declare (ignore request)) + *weblocks-default-app- name*)) + + +(defmethod acceptor-dispatch-request ((acceptor weblocks-acceptor) request) + "Like easy-acceptor's method, but in the end call/start our default app" + (loop for dispatcher in *dispatch-table* + for action = (funcall dispatcher request) + when action return (funcall action) + finally + (if (null (tokenize-uri (script-name*) nil)) + (let* ((webapp-name (funcall *weblocks-default-app- name-fn* request)) + (webapp (or (get-webapp webapp-name nil) + (start-webapp webapp-name)))) + (redirect (weblocks-webapp-prefix webapp))) + (call-next-method)))) + + + -- You received this message because you are subscribed to the Google Groups "weblocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/weblocks?hl=en.
