SaturnFramework / Saturn

Opinionated, web development framework for F# which implements the server-side, functional MVC pattern
https://saturnframework.org
MIT License
708 stars 108 forks source link

Routing with string ids #210

Closed scorelocity closed 4 years ago

scorelocity commented 4 years ago

I'm trying to set up routing for a controller using string ids. As I understand it, the correct way to do this is:

forward "/books" booksController

My controller actions that require ids are set up like (note the use of string format strings) :

show (fun ctx id -> (sprintf "Show handler version 1 - %s" id) |> Controller.text ctx) //Show details of a user
edit (fun ctx id -> (sprintf "Edit handler version 1 - %s" id) |> Controller.text ctx) //Edit a user

However, for both of the following urls:

http://localhost:8085/books/abcde http://localhost:8085/books/abcde/edit

the show action is triggered and I see "Show handler version 1 - abcde" in my browser.

When I change this to use integer format strings in the controller actions, this works as expected, i.e. the edit action is triggered when I use the edit url.

Am I setting this routing up incorrectly? Thanks.

ChrSteinert commented 4 years ago

I have looked into this and have no idea what's wrong. The route setup looks correct, and works, when you do it manually (via router {}). I suspected that the routes get configured for the controller in a wrong order, but this also does not seem to be the case.