Last active
August 29, 2015 14:02
-
-
Save kylone/a8e186f46f0868d46043 to your computer and use it in GitHub Desktop.
Module for declaring MVC route configurations in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// MVC Route configurations | |
module RouteConfig = | |
open System.Web.Mvc | |
open System.Web.Routing | |
let registerRoutes (routes: RouteCollection) = | |
routes.IgnoreRoute("{resource}.axd/{*pathInfo}") | |
/// create a pair, boxing the second item | |
let inline (=>) a b = a, box b | |
/// set the Defaults property from a given dictionary | |
let setDefaults defaultDict (route : Route) = | |
route.Defaults <- RouteValueDictionary(defaultDict) | |
routes.MapRoute(name="Default", url="{controller}/{action}/{id}") | |
|> setDefaults (dict ["controller" => "Home" | |
"action" => "Index" | |
"id" => UrlParameter.Optional]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment