-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router handling prefix incorrectly when using Jetty server #2
Comments
FWIW I did a tiny bit of digging and I wonder if this method in http4s-servlet could be a problem? It looks like I have zero experience with the internals of http4s, so apologies if that's way off 😬 |
@talbotja I think you're hitting the same bug as I did in http4s/http4s#5100. And I agree with you that |
@fthomas ah yes thanks, that does look like exactly the same thing. I confirmed the same issue exists using tomcat as the server too, which makes sense given that that's the other use of I tried out your proposed fix locally and it does fix the issue I'm seeing 👍 |
@talbotja I currently don't have time to bring http4s/http4s#5100 in a mergeable state. So if you're inclined to fix this issue yourself, fell free to go ahead. |
Apologies for the delay on this, but I actually have some time I could spend on this this week. What would need to be done in order for something like the proposed change in http4s/http4s#5100 to be mergeable? Some tidying up of the code in |
Fantastic! It looks like @hamnis had some ideas what to do in http4s/http4s#5100. |
Any movement on this? I think we're hitting the same issue with a setup like this: val r = Router(
"/ping" -> PingRoutes.routes
)
class PingRoutes extends Http4sDsl[IO] {
def routes: HttpRoutes[IO] = {
HttpRoutes.of[IO] {
case GET -> Root => Ok("pong")
}
}
|
@xnejp03 I don't remember seeing any PRs relating to this. Would be great if someone can pick it up. |
Is this not one? http4s/http4s#5100 |
Yes, sorry I should clarify: I haven't seen any PRs attempting to fix this :) that PR says:
There are some pointers in the comments that may be useful. Edit: nope, I'm wrong again, apologies. I guess that PR does propose a fix too :) seems like it needed additional investigation though. |
I can have a look into this problem tomorrow. |
Well... this is a rabbit hole. The http4s/http4s#5100 patches up the obvious problem, but it doesn't address the underlaying issue of some quirky edge-cases in |
This issue has been fixed in |
If I use a
Router
where the prefix includes a forward slash, I would expect the whole prefix to be stripped from the request before matching on the inner routes. More specifically, if I have routes like this:And I make a request to
pref-a/pref-b/my-resource
, I would expect to be able to matchRoot / "my-resource"
withinmyRoutes
.This appears to work as expected if I use blaze as the server, but if I use jetty it only removes the first segment of the prefix, meaning that I have to match
Root / "pref-b" / "my-resource"
.Not sure how good a job I did explaining that, so I have reproduced it in this repo. It spins up jetty on 8080 and blaze on 8081 serving the same routes. You can see that we get the expected behaviour from blaze but not from jetty.
The text was updated successfully, but these errors were encountered: