{"action":"created","issue":{"url":"https://api.github.com/repos/haskell-servant/servant/issues/214","labels_url":"https://api.github.com/repos/haskell-servant/servant/issues/214/labels{/name}","comments_url":"https://api.github.com/repos/haskell-servant/servant/issues/214/comments","events_url":"https://api.github.com/repos/haskell-servant/servant/issues/214/events","html_url":"https://github.com/haskell-servant/servant/pull/214","id":105052629,"number":214,"title":"Routing and errors (breaks tests).","user":{"login":"fisx","id":10210727,"avatar_url":"https://avatars.githubusercontent.com/u/10210727?v=3","gravatar_id":"","url":"https://api.github.com/users/fisx","html_url":"https://github.com/fisx","followers_url":"https://api.github.com/users/fisx/followers","following_url":"https://api.github.com/users/fisx/following{/other_user}","gists_url":"https://api.github.com/users/fisx/gists{/gist_id}","starred_url":"https://api.github.com/users/fisx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fisx/subscriptions","organizations_url":"https://api.github.com/users/fisx/orgs","repos_url":"https://api.github.com/users/fisx/repos","events_url":"https://api.github.com/users/fisx/events{/privacy}","received_events_url":"https://api.github.com/users/fisx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-09-05T22:12:10Z","updated_at":"2015-09-09T01:59:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/haskell-servant/servant/pulls/214","html_url":"https://github.com/haskell-servant/servant/pull/214","diff_url":"https://github.com/haskell-servant/servant/pull/214.diff","patch_url":"https://github.com/haskell-servant/servant/pull/214.patch"},"body":"Routing needs improvement.  I added a few test cases to model what I think we may want (comments welcome), and I get these\r\n\r\n```\r\nFailures:\r\n\r\n  src/Test/Hspec/Wai.hs:101:\r\n  1) Servant.Server, Handlers can trigger re-routing by responding with error status 404, re-route from /un handler, /un\r\n       status mismatch:\r\n         expected: 200\r\n         but got:  404\r\n       body mismatch:\r\n         expected: \"2\"\r\n         but got:  \"\"\r\n\r\n  src/Test/Hspec/Wai.hs:101:\r\n  2) Servant.Server, Broken request body triggers error response (not re-routing), happy handlers, (\"/sum\",\"[1, 2]\")\r\n       status mismatch:\r\n         expected: 200\r\n         but got:  415\r\n       body mismatch:\r\n         expected: 3\r\n         but got:  unsupported media type\r\n\r\n  src/Test/Hspec/Wai.hs:101:\r\n  3) Servant.Server, Broken request body triggers error response (not re-routing), parse error, (\"/sum\",\"@@@\")\r\n       status mismatch:\r\n         expected: 400\r\n         but got:  415\r\n\r\n  src/Test/Hspec/Wai.hs:101:\r\n  4) Servant.Server, Different methods on same end-point, (\"get\",\"/\")\r\n       status mismatch:\r\n         expected: 200\r\n         but got:  404\r\n       body mismatch:\r\n         expected: 3\r\n         but got:  not found\r\n\r\n  src/Test/Hspec/Wai.hs:101:\r\n  5) Servant.Server, Different methods on same end-point, (\"put\",\"/\")\r\n       status mismatch:\r\n         expected: 405\r\n         but got:  404\r\n```\r\n\r\nI suspect 2) is my fault, but I wanted to push this anyway.  1) is currently seriously biting us, and it would be great to get a quick fix at least in this branch.  @jkarni suspects it may be a matter of replacing a single `succeedWith` with a `failWith`.\r\n\r\nI put this out here FYI, will probably keep working on it."},"comment":{"url":"https://api.github.com/repos/haskell-servant/servant/issues/comments/138753053","html_url":"https://github.com/haskell-servant/servant/pull/214#issuecomment-138753053","issue_url":"https://api.github.com/repos/haskell-servant/servant/issues/214","id":138753053,"user":{"login":"imalsogreg","id":993484,"avatar_url":"https://avatars.githubusercontent.com/u/993484?v=3","gravatar_id":"","url":"https://api.github.com/users/imalsogreg","html_url":"https://github.com/imalsogreg","followers_url":"https://api.github.com/users/imalsogreg/followers","following_url":"https://api.github.com/users/imalsogreg/following{/other_user}","gists_url":"https://api.github.com/users/imalsogreg/gists{/gist_id}","starred_url":"https://api.github.com/users/imalsogreg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imalsogreg/subscriptions","organizations_url":"https://api.github.com/users/imalsogreg/orgs","repos_url":"https://api.github.com/users/imalsogreg/repos","events_url":"https://api.github.com/users/imalsogreg/events{/privacy}","received_events_url":"https://api.github.com/users/imalsogreg/received_events","type":"User","site_admin":false},"created_at":"2015-09-09T01:59:44Z","updated_at":"2015-09-09T01:59:44Z","body":"Re: the code @alpmestan posted, showing how `RouteMismatch`s are `mappend`ed together.. it might be nice if instead of reducing to a single `RouteResult`, we had `NodeMismatch` type, and while walking the API, we add nodes to the tree labeled by what happened there (success or failure). If the api is exhausted with no match, we return the whole tree of failures. If only a Raw matched, run the Raw handler and color that Raw node as 404 if the Raw handler is 404.\r\n\r\nOn success (when any non-raw route matches, or when a Raw route matches and runs without 404) discard the route history tree away return the handler's result. ? Not sure if it makes sense :)"}}