{"action":"created","issue":{"url":"https://api.github.com/repos/http4s/http4s/issues/338","labels_url":"https://api.github.com/repos/http4s/http4s/issues/338/labels{/name}","comments_url":"https://api.github.com/repos/http4s/http4s/issues/338/comments","events_url":"https://api.github.com/repos/http4s/http4s/issues/338/events","html_url":"https://github.com/http4s/http4s/issues/338","id":94126705,"number":338,"title":"Blaze backend doesn't route requests by path","user":{"login":"mossprescott","id":6147371,"avatar_url":"https://avatars.githubusercontent.com/u/6147371?v=3","gravatar_id":"","url":"https://api.github.com/users/mossprescott","html_url":"https://github.com/mossprescott","followers_url":"https://api.github.com/users/mossprescott/followers","following_url":"https://api.github.com/users/mossprescott/following{/other_user}","gists_url":"https://api.github.com/users/mossprescott/gists{/gist_id}","starred_url":"https://api.github.com/users/mossprescott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mossprescott/subscriptions","organizations_url":"https://api.github.com/users/mossprescott/orgs","repos_url":"https://api.github.com/users/mossprescott/repos","events_url":"https://api.github.com/users/mossprescott/events{/privacy}","received_events_url":"https://api.github.com/users/mossprescott/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/http4s/http4s/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-09T19:00:30Z","updated_at":"2015-07-09T23:42:09Z","closed_at":null,"body":"If multiple services are mounted with different prefixes, the Jetty backend will map requests to just the correct service in what seems to be a reasonable way, with only matching request paths being handled by each service, and the prefix stripped from the path by the time it reaches the service.\r\n\r\nWith the Blaze backend, all requests seem to be offered to the last-mounted service first, and the path is altered just by having the number of characters in the prefix stripped off (even if they don't match).\r\n\r\nGiven the setup below:\r\n1. `GET /a/foo` gets handled by the service mounted at `/x`, with the path `/foo`.\r\n2. `GET /abc/foo` also gets handle by the wrong service, and the path is `/bc/foo`.\r\n\r\nThis behavior makes it impossible to mount multiple services that interpret the path in some way (rather than simply matching some particular paths.) I believe it can be worked around by making sure that each service imposes enough constraints on the path to never be defined for a request intended for another service. Another workaround, which I'm experimenting with, would be to write a `Prefix` middleware that matches and rewrites the paths correctly.\r\n\r\nTested with http4s 0.8.2.\r\n\r\n```scala\r\nobject BlazeTest extends App {\r\n  def service(id: String) = HttpService {\r\n    case GET -> path => Ok(id + \"; path: \" + path)\r\n  }\r\n\r\n  val js = org.http4s.server.jetty.JettyBuilder\r\n    .withIdleTimeout(1.second)\r\n    .bindHttp(8080, \"0.0.0.0\")\r\n    .mountService(service(\"abc\"), \"/abc\")\r\n    .mountService(service(\"x\"), \"/x\")\r\n\r\n  val bs = org.http4s.server.blaze.BlazeBuilder\r\n    .withIdleTimeout(1.second)\r\n    .bindHttp(8180, \"0.0.0.0\")\r\n    .mountService(service(\"abc\"), \"/abc\")\r\n    .mountService(service(\"x\"), \"/x\")\r\n\r\n  js.run\r\n  bs.run\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/http4s/http4s/issues/comments/120175374","html_url":"https://github.com/http4s/http4s/issues/338#issuecomment-120175374","issue_url":"https://api.github.com/repos/http4s/http4s/issues/338","id":120175374,"user":{"login":"bryce-anderson","id":2948506,"avatar_url":"https://avatars.githubusercontent.com/u/2948506?v=3","gravatar_id":"","url":"https://api.github.com/users/bryce-anderson","html_url":"https://github.com/bryce-anderson","followers_url":"https://api.github.com/users/bryce-anderson/followers","following_url":"https://api.github.com/users/bryce-anderson/following{/other_user}","gists_url":"https://api.github.com/users/bryce-anderson/gists{/gist_id}","starred_url":"https://api.github.com/users/bryce-anderson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryce-anderson/subscriptions","organizations_url":"https://api.github.com/users/bryce-anderson/orgs","repos_url":"https://api.github.com/users/bryce-anderson/repos","events_url":"https://api.github.com/users/bryce-anderson/events{/privacy}","received_events_url":"https://api.github.com/users/bryce-anderson/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T23:42:09Z","updated_at":"2015-07-09T23:42:09Z","body":"@mossprescott, I have a branch up to fix this issue. I took a different strategy than you have, so some testing is in order. I will likely be making another commit with a unit test before the PR lands."}}