Commits

Luke Plant committed 838dff0

Added addSlashRedirectProcessor to procs for blog

  • Participants
  • Parent commits 7a70b8b

Comments (0)

Files changed (3)

         regex-pcre,
         regex-base,
         xhtml,
+        network,
         cgi
   Main-is: BlogCgi.hs
   hs-source-dirs: src

File src/Blog/Routes.hs

 module Blog.Routes where
 
+import Blog.Views
 import Web.Framework
-import Blog.Views
+import Web.Framework.Processors (addSlashRedirectProcessor)
+import Web.GenUtils (apply)
 
 -- * Routes
 
 -- These need to be manually synced with Blog.Links
 
-routes = [ empty                                      //-> mainIndex
+views' = [ empty                                      //-> mainIndex
          , "posts/" <+/> stringParam                  //-> postView
          , "posts/" <+/> empty                        //-> postsRedirectView
          , "categories/" <+/> empty                   //-> categoriesView
          , "categories/" <+/> stringParam             //-> categoryView
          , "debug/" <+/> stringParam                  //-> debug
          ]
+
+-- Apply global processors to all views
+procs = [addSlashRedirectProcessor]
+
+views = map (apply procs) views'

File src/BlogCgi.hs

 import Web.Framework
 
 main :: IO ()
-main = dispatchCGI routes defaultDispatchOptions
+main = dispatchCGI views defaultDispatchOptions