-
Notifications
You must be signed in to change notification settings - Fork 594
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
PathMatcher DSL: Map Matcher problem (?) #394
Comments
I could have a look in the code to see if I can find and fix the problem. |
Reproducible with the following test in PathDirectivesSpec.scala: "path(Map(\"sv\" -> 1, \"sv_SE\" -> 2, \"en\" -> 3))" should {
val test = testFor(path(Map("sv" → 1, "sv_SE" → 2, "en" → 3)) { echoCaptureAndUnmatchedPath })
"accept [/sv]" inThe test("1:")
"accept [/sv_SE]" inThe test("2:")
"reject [/sv_FI]" inThe test()
"reject [/fr]" inThe test()
} Looking at the Scaladoc it sounds like a bug, but I will let somebody from the Akka team answer that question.
|
@jonas I am not sure that the This aspect is clearly reflected in the conversion implicit - https://github.com/akka/akka-http/blob/master/akka-http/src/main/scala/akka/http/scaladsl/server/PathMatcher.scala#L295-L298 On the other hand, looking into docs, it is stated (as @sbrugnoni has quoted) that one can use All in all looks like a complex interplay between A couple of interesting test cases (run in the context of
|
Fun fact: pasted those examples into spray. Got different pattern of failures (probably because the implementation is based on HLists in spray vs. Tuples in akka-http. Nota bene the spray-routing documentation page for PathMatcher DSL has the same text as akka-http for both |
@gosubpl I looked a bit more into it myself, and it seems that this behaviour is not exclusive to the valueMap matcher.
whereas changing the segment order again results in the (at least for me) expected behaviour:
Seems like having overlapping paths in general is a bad idea. |
@jrudolph It would be great to have your input on this. It looks trivial to fix for 10.0.0 if it is indeed a bug. Right now the result is nondeterministic (i.e. relying on order of map entries) so the outcome could be to document it. |
Match path maps in order of longest matching key prefix (#394)
Solved by #586 will be in 10.0.2 |
Given the following setup, describing two resources "/a" and "/aa", all requests to "/aa" get rejected.
According to the documentation, the
Map[String, T]
matcher should match "any of the keys and extracts the respective map value for it".See Documentation
I assume the cause for this issue is common prefix (in this case "a") of the two resources.
If the order of the resources in the definition of the route is reversed, it works as expected:
I have a unit test that reproduces this problem with akka-http-experimental 2.4.11
The text was updated successfully, but these errors were encountered: