-
Notifications
You must be signed in to change notification settings - Fork 261
Closed
Description
I'd like to create a routing system similar to Rails, e.g. /users, /users/123, /users/new. I haven't been able to figure out how to do this with Reitit. I tried this which fails
(let [rtr (r/router ["/users"
["" :user/list]
["/new" :user/new]
["/:id" :user/detail]])]
[(r/match-by-path rtr "/users")
(r/match-by-path rtr "/users/new")
(r/match-by-path rtr "/users/123")])
Execution error (ExceptionInfo) at reitit.exception/exception (exception.cljc:19).
Router contains conflicting route paths:
-> /users/new
-> /users/:id I tried setting :conflicting in various combinations on these routes but I couldn't find any combination that worked correctly.
(let [rtr (r/router ["/users"
["" :user/list]
["/new" :user/new {:conflicting true}]
["/:id" :user/detail]])]
[(r/match-by-path rtr "/users")
(r/match-by-path rtr "/users/new")
(r/match-by-path rtr "/users/123")])Is this kind of routing supported? I'd like to be able to specify that :user/detail has a numeric :id so it could be disambiguated from /new. Inside :user/detail I could check for a path param of new and dispatch back out to :user/new, but that doesn't feel very clean.
Metadata
Metadata
Assignees
Labels
No labels