On 17/03/2017 21:25, Daniel Stoner wrote:

What I wanted to do - was nest paths inside of each other thinking:
path("v1") {
path("orders") {whatever}
path("customers") {whatever}
}

Yes, exactly so.

In practice it appears that it works more as though each nested path does
not operate on the remaining unmatched path - but actually the whole url.
In a sense the above code is saying match paths that both look like: START
- /v1/ - END AND START - /orders/ - END. Obviously an impossible situation.

I believe that's why you need to use "~" or concat, so the alternatives are tried in order.

So what we do is simply enumerate the paths we want to match for (rather
than nest them) and use PathMatcher DSL to enable us to avoid any real
overhead to the code for this. In the end it's just as readable (If not a
little bit more so since your enumerating explicitly your matching
possibilities rather than nesting them).

The problem is I have hundreds of paths to match, listing each individual path in full in a linear fashion is just unworkable, I need to use a tree.

One practices we found that worked - do the splitting by HTTP method
(GET/POST/PUT) down at the lowest level. Often you have a URL like
/v1/orders that accepts GET, PUT and POST and then you can nest all 3
options under one path matcher.

Yes, that's what I've done.

I really believe the current behaviour is the wrong choice, although I've found hints in the documentation that it is deliberate - I have no idea why it was considered to be a good design, if indeed it was.

I'm trying to figure out how to write my own implementation of Segment("foo") to allow complete matching of a path segment, but it's not easy as the DSL implementation is pretty "dense" code.

--
Alan Burlison
--

--
     Read the docs: http://akka.io/docs/
     Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
     Search the archives: https://groups.google.com/group/akka-user
--- You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to