[hunchentoot-devel] Middleware with Hunchentoot

Mac Chan emailmac at gmail.com
Fri Jul 20 06:34:23 UTC 2007


> (defmacro with-authentication (&body body)
>   `(progn
>     (require-authorization)
>     , at body))

Ah, I forget to reread my email before I click send.

It should be something like this:

(defun do-authorization ()
  (multiple-value-bind (user password)
      (authorization)
    (unless (and (equal user "nanook")
                 (equal password "igloo"))
      (require-authorization))))

(defmacro with-authentication (&body body)
  `(progn
    (do-authorization)
    , at body))


> (define-easy-handler (my-url-handler :uri "/my-url") ()
>  (require-authorization)
>  (with-html (:h1 "hi"))

Similarly the above is wrong.

(define-easy-handler (my-url-handler :uri "/my-url") ()
 (do-authorization)
 (with-html (:h1 "hi"))

BTW none of the code are tested, but you get the idea ...

Regards,
-- Mac



More information about the Tbnl-devel mailing list