common-lisphunchentoot

Is there a way to have the hunchentoot:*dispatch-table* update automatically on function redefinition?


I have set up the dispatch-table in the following-manner:

(setq hunchentoot:*dispatch-table*
        (mapcar #'(lambda (regex-and-handler)
                    (hunchentoot:create-regex-dispatcher (first regex-and-handler)
                                                         (second regex-and-handler)))
                (list (list "^/one$" #'page-one)
                      (list "^/two$" #'page-two))))

Now, if I redefine the function page-one, the *dispatch-table* still uses the old definition, and uses the new definition only when the (setq ...) form is re-evaluated. Is there a way to get it to pick up the new function definition?


Solution

  • Use the function's names, as a symbol, instead of resolving the symbol to a function object with function (reader syntax #') when evaluating the list. In other words:

    ....
    (list (list "^/one$" 'page-one)
          (list "^/two$" 'page-two))))