Hi!
(defun create-host-dispatch-proxy (host dispatcher) "Creates a proxy dispatcher which calls the given DISPATCHER when the HOST matches." (lambda (request) (when (and (host request) (string-equal host (host request))) (funcall dispatcher request))))
[Function] create-host-dispatch-proxy host dispatcher => dispatch-fn
A convenience function which will return a dispatcher which calls the given dispatcher when the host matches.
Purpose: Use the known functions for creating a dispatcher but add the feature to match the host first.
Example: (create-host-dispatch-proxy "www.zappa.test" (create-static-file-dispatcher-and-handler "/tbnl/test/image.jpg" (make-pathname :name "fz" :type "jpg" :version nil :defaults (load-time-value *load-pathname*)) "image/jpeg"))
(create-host-dispatch-proxy "www.king.test" (create-static-file-dispatcher-and-handler "/tbnl/test/image.jpg" (make-pathname :name "elvis" :type "jpg" :version nil :defaults (load-time-value *load-pathname*)) "image/jpeg"))
This delivers fz.jpg on http://www.zappa.test/tbnl/test/image.jpg and elvis.jpg on http://www.king.test/tbnl/test/image.jpg
Name has the word "proxy" in it. It's the right name, but it's no web-proxy as the user would expect. Other name for the function?
The documentation uses the word "dispatcher" two times but one time it's the one created and the second time it's the one given in the lambda list. Hard to understand?
Not easy to use in test/test.lisp.
I don't know if this code should be included into TBNL. The list of convenience functions grows on and could become a bit complex. I see it more as an example on how to solve a certain problem when you want to run one lisp image with different (virtual) webserver addresses.
But feel free to add it anyway.
Regards, Stefan
On Tue, 27 Jul 2004 14:01:48 +0200, Stefan Scholl stesch@no-spoon.de wrote:
I don't know if this code should be included into TBNL. The list of convenience functions grows on and could become a bit complex. I see it more as an example on how to solve a certain problem when you want to run one lisp image with different (virtual) webserver addresses.
I don't think it should be added because a) it's rather easy to do it yourself and b) I think it'll rarely be used. I guess that if two virtual hosts use the same TBNL image than they're usually handled as if they were equal - otherwise you'd use Apache's virtual hosts to dispatch to different Lisp images.
Cheers, Edi.