{"action":"created","issue":{"url":"https://api.github.com/repos/civetweb/civetweb/issues/179","repository_url":"https://api.github.com/repos/civetweb/civetweb","labels_url":"https://api.github.com/repos/civetweb/civetweb/issues/179/labels{/name}","comments_url":"https://api.github.com/repos/civetweb/civetweb/issues/179/comments","events_url":"https://api.github.com/repos/civetweb/civetweb/issues/179/events","html_url":"https://github.com/civetweb/civetweb/issues/179","id":97435988,"number":179,"title":"URI Handler for partial matches select first partial match instead of closest match","user":{"login":"cdbishop","id":5167538,"avatar_url":"https://avatars.githubusercontent.com/u/5167538?v=3","gravatar_id":"","url":"https://api.github.com/users/cdbishop","html_url":"https://github.com/cdbishop","followers_url":"https://api.github.com/users/cdbishop/followers","following_url":"https://api.github.com/users/cdbishop/following{/other_user}","gists_url":"https://api.github.com/users/cdbishop/gists{/gist_id}","starred_url":"https://api.github.com/users/cdbishop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdbishop/subscriptions","organizations_url":"https://api.github.com/users/cdbishop/orgs","repos_url":"https://api.github.com/users/cdbishop/repos","events_url":"https://api.github.com/users/cdbishop/events{/privacy}","received_events_url":"https://api.github.com/users/cdbishop/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2015-07-27T10:48:27Z","updated_at":"2016-07-14T20:13:32Z","closed_at":null,"body":"In the embedded_c example there is a handle for /A and for /A/B.\r\n\r\nIf I run up the embedded_c sample and perform a request at the path /A/B/C, I would expect the request to be handled by /A/B, but in reality this request is handled by handler at /A.\r\n\r\nThe reason appears to be because the partial matches are performed in the order that the handlers where added, thus it partially matches /A successfully before checking /A/B. \r\n\r\nAs a work around I, as the user can ensure that I add my handlers in order of most nested first e.g.\r\n\r\nmg_set_request_handler(\"/A/B\", ABHandler)\r\nmg_set_request_handler(\"/A\", AHandler)\r\n\r\nBut it would be great if I didn't have to worry about the addition order (as I have additions in different areas of my code)\r\n\r\nI think a solution to this would be to have the handlers sorted by uri length (longest first). This could be done when one is set (in the mg_set_request_handler_type) by inserting the handler in the list such that they are ordered longest to shortest. That way Uri's with deep nesting would be checked first.\r\n\r\nI can look into creating a pull request with this change if you agree with my expectation of finding the closest match in a partial search."},"comment":{"url":"https://api.github.com/repos/civetweb/civetweb/issues/comments/232778591","html_url":"https://github.com/civetweb/civetweb/issues/179#issuecomment-232778591","issue_url":"https://api.github.com/repos/civetweb/civetweb/issues/179","id":232778591,"user":{"login":"bel2125","id":5619191,"avatar_url":"https://avatars.githubusercontent.com/u/5619191?v=3","gravatar_id":"","url":"https://api.github.com/users/bel2125","html_url":"https://github.com/bel2125","followers_url":"https://api.github.com/users/bel2125/followers","following_url":"https://api.github.com/users/bel2125/following{/other_user}","gists_url":"https://api.github.com/users/bel2125/gists{/gist_id}","starred_url":"https://api.github.com/users/bel2125/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bel2125/subscriptions","organizations_url":"https://api.github.com/users/bel2125/orgs","repos_url":"https://api.github.com/users/bel2125/repos","events_url":"https://api.github.com/users/bel2125/events{/privacy}","received_events_url":"https://api.github.com/users/bel2125/received_events","type":"User","site_admin":false},"created_at":"2016-07-14T20:13:31Z","updated_at":"2016-07-14T20:13:31Z","body":"Probably, a new interface to match URIs according to https://tools.ietf.org/html/rfc6570 would be the best solution. It would have to have a list of variables found while matching the URI patterns.\r\n"}}
{"actor":{"display_login":"bel2125"}}