RouteProvider
RouteProvider is an F# Type provider that generates types suitable for routing in a web application.
PM> Install-Package RouteProvider -Pre
Example
This example initializes RouteProvider with 5 different routes:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: |
|
From this invocation, we'll get a type generated that looks like this
1: 2: 3: |
|
We can then build routes using this type in a strongly typed way:
1: 2: |
|
We can also create a router:
1: 2: 3: 4: 5: 6: |
|
We can then dispatch routes to this router like this, and the appropriate handler will be executed:
1: 2: |
|
RouteProvider can also provide generic input arguments to integrate with web libraries. See the Suave example.
Sample projects
Simple A basic command line example
Owin Input type A basic web app with a few routes, using an Owin input type
ASP.Net MVC Taking over routing for ASP.NET MVC
Suave An example with Suave, integrating by using a generic input and return type.
API Reference automatically generated documentation for all types
Code generation samples:
Contributing and copyright
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding a new public API, please also consider adding samples that can be turned into a documentation. You might also want to read the library design notes to understand how it works.
The library is available under the MIT license. For more information see the License file in the GitHub repository.
type LiteralAttribute =
inherit Attribute
new : unit -> LiteralAttribute
Full name: Microsoft.FSharp.Core.LiteralAttribute
--------------------
new : unit -> LiteralAttribute
Full name: Index.routes
Full name: Index.outputPath
type Dummy =
new : unit -> Dummy
Full name: Index.Dummy
--------------------
Dummy() : Dummy
namespace IsakSky.RouteProvider
--------------------
type RouteProvider =
new : unit -> RouteProvider
Full name: IsakSky.RouteProvider
--------------------
IsakSky.RouteProvider.RouteProvider() : IsakSky.RouteProvider.RouteProvider
from MyNamespace
Full name: Index.HoverMe
{getProject: int64 -> unit;
updateProject: string -> unit;
createProject: string -> unit;
getProjectComments: int64 -> int64 -> unit;
notFound: (string -> string -> unit) option;}
member DispatchRoute : verb:string * path:string -> unit
member DispatchRoute : verb:string * uri:Uri -> unit
member private HandleNotFound : verb:string * path:string -> unit
static member Router : getProject:(int64 -> unit) * updateProject:(string -> unit) * createProject:(string -> unit) * getProjectComments:(int64 -> int64 -> unit) * ?notFound:(string -> string -> unit) -> MyRoutes
Full name: MyNamespace.MyModule.MyRoutes
Full name: Index.path1
Full name: MyNamespace.MyModule.getProjectComments
Full name: Index.path2
Full name: MyNamespace.MyModule.createProject
Full name: Index.router
Full name: MyNamespace.MyModule.getProject
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
Full name: MyNamespace.MyModule.updateProject
member MyRoutes.DispatchRoute : verb:string * uri:System.Uri -> unit