URL handling
authorAdam Chlipala <adamc@hcoop.net>
Sun, 6 Aug 2006 22:11:40 +0000 (22:11 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sun, 6 Aug 2006 22:11:40 +0000 (22:11 +0000)
lib/alias.dtl
lib/domain.dtl
lib/urls.dtl [new file with mode: 0644]
src/domain.sml
src/plugins/apache.sml
tests/testApache.dtl

index b7ccae4..8fe2246 100644 (file)
@@ -32,7 +32,7 @@ extern val aliasPrim : aliasSource -> aliasTarget -> [Domain] {MailNodes: [node]
 {{Request redirection of all mail from the source to the target, specifying on
   which nodes this redirection should be applied.}}
 
 {{Request redirection of all mail from the source to the target, specifying on
   which nodes this redirection should be applied.}}
 
-val alias = \user -> \email -> aliasPrim (userSource user) (addressTarget email);
+val emailAlias = \user -> \email -> aliasPrim (userSource user) (addressTarget email);
 {{Redirect mail for the user at the current domain to the e-mail address.}}
 val aliasMulti = \user -> \emails -> aliasPrim (userSource user) (addressesTarget emails);
 {{Redirect mail for the user at the current domain to all of the e-mail
 {{Redirect mail for the user at the current domain to the e-mail address.}}
 val aliasMulti = \user -> \emails -> aliasPrim (userSource user) (addressesTarget emails);
 {{Redirect mail for the user at the current domain to all of the e-mail
index 62256ed..0ab7716 100644 (file)
@@ -3,6 +3,9 @@
 extern type no_spaces;
 {{Any string with no space characters}}
 
 extern type no_spaces;
 {{Any string with no space characters}}
 
+extern type no_newlines;
+{{Any string with no newline characters}}
+
 extern type ip;
 {{An IP address}}
 
 extern type ip;
 {{An IP address}}
 
diff --git a/lib/urls.dtl b/lib/urls.dtl
new file mode 100644 (file)
index 0000000..89bac62
--- /dev/null
@@ -0,0 +1,11 @@
+{{Basic Apache URL handling}}
+
+extern val alias : location -> your_path -> [Vhost];
+{{All requests for the location should be served from the path.}}
+
+extern val scriptAlias : location -> your_path -> [Vhost];
+{{Like <tt>alias</tt>, for Apache's <tt>ScriptAlias</tt>}}
+
+extern val errorDocument : no_spaces -> no_newlines -> [^Vhost];
+{{The first argument specifies an HTTP error code, which should be handled using
+  the second argument, which is either a URL or a string to display.}}
index 91d8005..71d448d 100644 (file)
@@ -74,6 +74,9 @@ fun yourPath path =
 val _ = Env.type_one "no_spaces"
                     Env.string
                     (CharVector.all (fn ch => not (Char.isSpace ch)))
 val _ = Env.type_one "no_spaces"
                     Env.string
                     (CharVector.all (fn ch => not (Char.isSpace ch)))
+val _ = Env.type_one "no_newlines"
+                    Env.string
+                    (CharVector.all (fn ch => ch <> #"\n" andalso ch <> #"\r"))
 
 val _ = Env.type_one "ip"
        Env.string
 
 val _ = Env.type_one "ip"
        Env.string
index 878204b..4ea8f22 100644 (file)
@@ -303,4 +303,32 @@ val () = Env.action_three "rewriteCond"
                                 write "]");
              write "\n"))
 
                                 write "]");
              write "\n"))
 
+val () = Env.action_two "alias"
+        ("from", Env.string, "to", Env.string)
+        (fn (from, to) =>
+            (write "\tAlias\t";
+             write from;
+             write " ";
+             write to;
+             write "\n"))
+
+val () = Env.action_two "scriptAlias"
+        ("from", Env.string, "to", Env.string)
+        (fn (from, to) =>
+            (write "\tScriptAlias\t";
+             write from;
+             write " ";
+             write to;
+             write "\n"))
+
+val () = Env.action_two "errorDocument"
+        ("code", Env.string, "handler", Env.string)
+        (fn (code, handler) =>
+            (write "\tErrorDocument\t";
+             write code;
+             write " ";
+             write handler;
+             write "\n"))
+
+
 end
 end
index 7e57594..c8438ff 100644 (file)
@@ -25,6 +25,9 @@ domain "hcoop.net" with
                proxyPass "/proxyLand" "http://localhost:1234/otherProxyLand";
                proxyPassReverse "/proxyLand" "http://localhost:1234/otherProxyLand";
 
                proxyPass "/proxyLand" "http://localhost:1234/otherProxyLand";
                proxyPassReverse "/proxyLand" "http://localhost:1234/otherProxyLand";
 
+               scriptAlias "/cgi-bin/that-script" "/home/adamc/cgi/here-it-is";
+               errorDocument "404" "I just couldn't find it.";
+
                directory "/home/adamc/thisPlace" with
                        rewriteRule "A" "B" [];
                end
                directory "/home/adamc/thisPlace" with
                        rewriteRule "A" "B" [];
                end
@@ -32,5 +35,6 @@ domain "hcoop.net" with
 
        vhost "lists" with
                proxyPass "/mailman" "http://hcoop.net/cgi-bin/mailman";
 
        vhost "lists" with
                proxyPass "/mailman" "http://hcoop.net/cgi-bin/mailman";
+               alias "/doc/mailman" "/home/adamc/mailman"
        end
 end
        end
 end