scala/lift/Boot.scala: useful rules (utf8, end/ fix)
authorTomas Zeman <tzeman@volny.cz>
Fri, 22 Oct 2010 13:55:59 +0200
changeset 5 824fbbce8e65
parent 4 5ef63a5d98b2
child 6 b2c3a430fd59
scala/lift/Boot.scala: useful rules (utf8, end/ fix)
scala/lift/Boot.scala
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scala/lift/Boot.scala	Fri Oct 22 13:55:59 2010 +0200
@@ -0,0 +1,22 @@
+/* additions to Boot.scala */
+
+class Boot extends Logger {
+
+  def boot = {
+    ...
+
+    /* Handle end slash and drop it (except for home page) */
+    LiftRules.statelessRewrite.append {
+      case RewriteRequest(ParsePath(xs,_,_,true),_,_) if (xs.size > 1) &&
+        (xs.lastOption == Some("index")) =>
+          RewriteResponse(xs dropRight 1)
+                                    }
+
+    /* Http conf */
+    LiftRules.logServiceRequestTiming = false
+    LiftRules.early.append(_.setCharacterEncoding("UTF-8"))
+
+  }
+}
+
+// vim: set ts=2 sw=2 et: