1 IN: http.server.rewrite
2 USING: help.syntax help.markup http.server ;
5 { $class-description "The class of directory rewrite responders. The slots are as follows:"
7 { { $slot "default" } " - the responder to call if no file name is provided." }
8 { { $slot "child" } " - the responder to call if a file name is provided." }
9 { { $slot "param" } " - the name of a request parameter which will store the first path component of the file name passed to the responder." }
13 { $values { "rewrite" rewrite } }
14 { $description "Creates a new " { $link rewrite } " responder." }
18 " <display-post-action> >>default"
19 " <display-comment-action> >>child"
20 " \"comment_id\" >>param"
25 { $class-description "The class of virtual host rewrite responders. The slots are as follows:"
27 { { $slot "default" } " - the responder to call if no host name prefix is provided." }
28 { { $slot "child" } " - the responder to call if a host name prefix is provided." }
29 { { $slot "param" } " - the name of a request parameter which will store the first host name component of the host name passed to the responder." }
30 { { $slot "suffix" } " - the domain name suffix which will be chopped off the end of the request's host name in order to produce the parameter." }
34 { $values { "vhost-rewrite" vhost-rewrite } }
35 { $description "Creates a new " { $link vhost-rewrite } " responder." }
39 " <show-blogs-action> >>default"
40 " <display-blog-action> >>child"
41 " \"blog_id\" >>param"
42 " \"blogs.vegan.net\" >>suffix"
46 ARTICLE: "http.server.rewrite.overview" "Rewrite responder overview"
47 "Rewrite responders take the file name and turn it into a request parameter named by the " { $slot "param" } " slot before delegating to a child responder. If a file name is provided, it calls the responder in the " { $slot "child" } " slot. If no file name is provided, they call the default responder in the " { $slot "default" } " slot."
49 "For example, suppose you want to have the following website schema:"
51 { { $snippet "/posts/" } " - show a list of posts" }
52 { { $snippet "/posts/factor_language" } " - show thread with ID " { $snippet "factor_language" } }
53 { { $snippet "/posts/factor_language/1" } " - show first comment in the thread with ID " { $snippet "factor_language" } }
54 { { $snippet "/animals" } ", ... - a bunch of other actions" } }
55 "One way to achieve this would be to have a nesting of responders as follows:"
57 { "A dispatcher at the top level" }
58 { "A " { $link rewrite } " as a child of the dispatcher under the name " { $snippet "posts" } ". The rewrite has the " { $slot "param" } " slot set to, say, " { $snippet "post_id" } ". The " { $slot "default" } " slot is set to a Furnace action which displays a list of posts." }
59 { "The child slot is set to a second " { $link rewrite } " instance, with " { $snippet "param" } " set to " { $snippet "comment_id" } ", the " { $slot "default" } " slot set to an action which displays a post identified by the " { $snippet "post_id" } " parameter, and the " { $snippet "child" } " slot set to an action which displays the comment identified by the " { $snippet "comment_id" } " parameter." } }
60 "Note that parameters can be extracted from the request using the " { $link param } " word, but most of the time you want to use " { $vocab-link "furnace.actions" } " instead." ;
62 ARTICLE: "http.server.rewrite" "URL rewrite responders"
63 "The " { $vocab-link "http.server.rewrite" } " vocabulary defines two responder types which can help make website URLs more human-friendly."
64 { $subsection "http.server.rewrite.overview" }
65 "Directory rewrite responders:"
66 { $subsection rewrite }
67 { $subsection <rewrite> }
68 "Virtual host rewrite responders -- these chop off the value in the " { $snippet "suffix" } " slot from the tail of the host name, and use the rest as the parameter value:"
69 { $subsection vhost-rewrite }
70 { $subsection <vhost-rewrite> } ;
72 ABOUT: "http.server.rewrite"