[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Suggestion for new egg: Wings!
From: |
Mario Domenech Goulart |
Subject: |
Re: [Chicken-users] Suggestion for new egg: Wings! |
Date: |
06 Jul 2007 15:06:54 -0300 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
On Fri, 6 Jul 2007 18:40:56 +0100 Alaric Snell-Pym <address@hidden> wrote:
> Why's http:find-resource need hacking?
Because http:find-resource searches for resources using something like
equal?.
url-dispatcher needs some resource finder which looks for resources
from a given pathname -- like regex matching.
For example, with the stock http:find-resource, and using
(register-dispatcher "/procs")
, an access to http://web.server/procs/add/1/2 would produce a 404
error (assuming /procs is empty).
The hacked http:find-resource looks for resources using regular expressions. So,
what register-dispatcher does behind the scenes is something like
(http:add-resource "/procs/.*" (lambda ...))
This way, the http-server can find whatever resource which matches
".*" under /procs (/procs is used as an environment). So we can have
the evaluation of (add "1" "2") in the `procs' environment.
This environment thing is particularly interesting because you can
have, say,
(register-dispatcher "/procs")
(register-dispatcher "/other-procs")
and each one have its own definition of `add', once you declare them
like:
(define-callable-url 'procs (add . args) ...)
(define-callable-url 'other-procs (add . args) ...)
But if you want `add' to be defined as a "toplevel" procedure, just
ommit the environment:
(define-callable-url (add . args) ...)
Best wishes,
Mario