Skip to content

Instantly share code, notes, and snippets.

@t0yv0
Created January 28, 2011 09:30
Show Gist options
  • Save t0yv0/800036 to your computer and use it in GitHub Desktop.
Save t0yv0/800036 to your computer and use it in GitHub Desktop.
let Router : Router<Action> =
let route = function
| GET (_, SPLIT_BY '/' []) ->
Some ShowRecentBlogs
| GET (_, SPLIT_BY '/' ["create"]) ->
Some CreateBlog
| GET (_, SPLIT_BY '/' ["read"; INT id]) ->
Some (ReadBlog id)
| GET (_, SPLIT_BY '/' ["update"; INT id]) ->
Some (UpdateBlog id)
| GET (_, SPLIT_BY '/' ["delete"; INT id]) ->
Some (DeleteBlog id)
| _ ->
None
let link x =
let uri =
match x with
| ShowRecentBlogs -> "/"
| CreateBlog -> "/create"
| ReadBlog x -> sprintf "/read/%i" x
| UpdateBlog x -> sprintf "/update/%i" x
| DeleteBlog x -> sprintf "/delete/%i" x
Some (Uri(uri, UriKind.Relative))
Router.New route link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment