Skip to content

Instantly share code, notes, and snippets.

@kylone
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylone/a8e186f46f0868d46043 to your computer and use it in GitHub Desktop.
Save kylone/a8e186f46f0868d46043 to your computer and use it in GitHub Desktop.
Module for declaring MVC route configurations in F#
/// 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