Open bruinbrown opened 10 years ago
Currently considering a few options for routing. Either
Attribute based routing. So every function which maps onto a route should have an attribute:
[<Route(path="users/hidden" method="GET")>]
let HiddenUsers input =
input
CreateRoute reqMethod basePath finalPath pathMatch =
I think option 2 is the better option personally. It could provide a really nice way of handling creating routes within a module. My thoughts on how it should work within a module are as follows.
module UsersModule =
let CreateUserRoute = CreateRoute "/users"
let simplePathMatch input =
AsJson input
do CreateUserRoute "GET" "/" simplePathMatch
I think that sits as being the best way of organising the parameters
In other related thoughts, currently the router inputs are a request and a response and it then needs to return a request and a response. This strikes me as being too much and there should be a different input and output which would still allow for direct access to the request and the response, then the router maps these onto the actual response. This would be to handle things like parameters passed within the URL.
Routing is currently in a semi functioning state. Further work to be done on it includes
I've been working on the way to create strongly typed access to route parameters lately and progress is good so far. It works through the use of a type provider, but I'm now looking at the best way of initialising it from a given set of routes.
The current options include:
RouteProvider<"/test/route/{id}">.Load(receivedPath)
IDictionary<string, string>
and parses through that
Routing will be a pipeline element which should run after authentication etc