Simple pathname dispatcher <dispatcher>
<new-action> "new" add-responder
<edit-action> "edit" add-responder
<delete-action> "delete" add-responder
<list-action> "" add-responder
main-responder set-global
In the above example, visiting any URL other than
/new ,
/edit ,
/delete , or
/ will result in a 404 error.
Another pathname dispatcher On the other hand, suppose we wanted to route all unrecognized paths to a "view" action:
<dispatcher>
<new-action> "new" add-responder
<edit-action> "edit" add-responder
<delete-action> "delete" add-responder
<view-action> >>default
main-responder set-global
The
default slot holds a responder to which all unrecognized paths are sent to.
Dispatcher subclassing example TUPLE: golf-courses < dispatcher ;
: <golf-courses> ( -- golf-courses )
golf-courses new-dispatcher ;
<golf-courses>
<new-action> "new" add-responder
<edit-action> "edit" add-responder
<delete-action> "delete" add-responder
<list-action> "" add-responder
main-responder set-global
The action templates can now emit links to responder-relative URLs prefixed by
$golf-courses/ .
Virtual hosting example <vhost-dispatcher>
<casino> "concatenative-casino.com" add-responder
<dating> "raptor-dating.com" add-responder
main-responder set-global
Note that the virtual host dispatcher strips off a
www. prefix, so
www.concatenative-casino.com would be routed to the
<casino> responder instead of receiving a 404.
This documentation was generated offline from a
load-all
image. If you want, you can also
browse the documentation from within the UI developer tools . See
the Factor website
for more information.
Factor 0.101 x86.64 (2285, heads/master-efda6dad2f, Nov 20 2024 16:02:37)