Created
January 28, 2011 09:30
-
-
Save t0yv0/800036 to your computer and use it in GitHub Desktop.
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
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