{"action":"created","issue":{"url":"https://api.github.com/repos/nitlang/nit/issues/2030","repository_url":"https://api.github.com/repos/nitlang/nit","labels_url":"https://api.github.com/repos/nitlang/nit/issues/2030/labels{/name}","comments_url":"https://api.github.com/repos/nitlang/nit/issues/2030/comments","events_url":"https://api.github.com/repos/nitlang/nit/issues/2030/events","html_url":"https://github.com/nitlang/nit/issues/2030","id":149971618,"number":2030,"title":"nitcorn paths","user":{"login":"Morriar","id":583144,"avatar_url":"https://avatars.githubusercontent.com/u/583144?v=3","gravatar_id":"","url":"https://api.github.com/users/Morriar","html_url":"https://github.com/Morriar","followers_url":"https://api.github.com/users/Morriar/followers","following_url":"https://api.github.com/users/Morriar/following{/other_user}","gists_url":"https://api.github.com/users/Morriar/gists{/gist_id}","starred_url":"https://api.github.com/users/Morriar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Morriar/subscriptions","organizations_url":"https://api.github.com/users/Morriar/orgs","repos_url":"https://api.github.com/users/Morriar/repos","events_url":"https://api.github.com/users/Morriar/events{/privacy}","received_events_url":"https://api.github.com/users/Morriar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nitlang/nit/labels/API","name":"API","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-21T05:34:07Z","updated_at":"2016-04-21T05:37:02Z","closed_at":null,"body":"Hello everyone, \r\n\r\nUntil now, nitcorn is very permissive regarding url matching.\r\n\r\nIf we take the route `/user`, here the matching of diverse routes:\r\n\r\n~~~\r\nfalse /\r\ntrue  /user\r\ntrue  /user/Morriar\r\ntrue  /user/Morriar/profile\r\n~~~\r\n\r\nThe same apply for vararg routes, for example with `/user/:id`\r\n\r\n~~~\r\nfalse /\r\nfalse  /user\r\ntrue  /user/Morriar\r\ntrue  /user/Morriar/profile\r\n~~~\r\n\r\nSince the route matching of nitcorn is based on the order of declaration of the routes, the following route/action declaration will always be redirected to `IndexAction`.\r\n\r\n~~~\r\n/ => IndexAction\r\n/user => UserListAction\r\n/user/Morriar => UserAction\r\n/user/Morriar/profile => UserProfileAction\r\n~~~\r\n\r\nThis can drives the developer crazy when handling 10+ routes...\r\n\r\nI suggest to tighten the route matching a bit here the proposed spec:\r\n\r\n* `/` maches only `/`\r\n* `/user` maches only `/user`\r\n* `/user/:id` maches only `/user/{someid}` but not `/user/{someid}/profile`\r\n* `/user/:id/profile` maches only `/user/{someid}/profile`\r\n\r\nTo make the migration easier and also because it is really useful, I propose a new kind of route suffixed by `*`.\r\n\r\n* `/*` maches everything (the current behavior of `/`)\r\n* `/user/*` maches `/user/{id}/` and `/user/{id}/profile` (not sure about `/user`, if I look at the current behavior of nitcorn regarding `/user` and `/user/`, I would go for `/user` is not matched)\r\n* `/user/:id/profile/*` maches `/user/{someid}/profile/foo/bar`\r\n\r\nI can submit a pull request that makes the change in the lib. @xymus @R4PaSs what do you think regarding you clients?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nitlang/nit/issues/comments/212751704","html_url":"https://github.com/nitlang/nit/issues/2030#issuecomment-212751704","issue_url":"https://api.github.com/repos/nitlang/nit/issues/2030","id":212751704,"user":{"login":"Morriar","id":583144,"avatar_url":"https://avatars.githubusercontent.com/u/583144?v=3","gravatar_id":"","url":"https://api.github.com/users/Morriar","html_url":"https://github.com/Morriar","followers_url":"https://api.github.com/users/Morriar/followers","following_url":"https://api.github.com/users/Morriar/following{/other_user}","gists_url":"https://api.github.com/users/Morriar/gists{/gist_id}","starred_url":"https://api.github.com/users/Morriar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Morriar/subscriptions","organizations_url":"https://api.github.com/users/Morriar/orgs","repos_url":"https://api.github.com/users/Morriar/repos","events_url":"https://api.github.com/users/Morriar/events{/privacy}","received_events_url":"https://api.github.com/users/Morriar/received_events","type":"User","site_admin":false},"created_at":"2016-04-21T05:37:02Z","updated_at":"2016-04-21T05:37:02Z","body":"Also, what about the matching priority?\r\n\r\n* for the request `user/profile` how to choose between routes `/user/:id` and `/user/:id`\r\n* for the request `user/profile` how to choose between routes `/user/` and `/user/*`"}}