I have 4 levels of URL based response. So for:
* GET to /abc answer should be abc
* GET on /abc/def answer should be def
* GET to /abc/def/ghi answer should be ghi
* GET on /abc/def/ghi/jkl answer should be (surprisingly) jkl
So my question is how to create such a request-response property using Spray.io?
I know that using pathPrefix with path possible, but is it only for two levels? With this approach, it should look something like this:
val route = { path("/abc") { // complete with response 'abc' } ~ path("/abc/def") { // complete with response 'def' } ~ path("/abc/def/ghi") { // complete with response 'ghi' } ~ path("/abc/def/ghi/jkl") { // complete with response 'jkl' } }
Is there a way to "nest paths"? I know this doesn't work, but just an idea like:
val route = { path("/abc") { // complete with response 'abc' 'sub'path("/def") { // complete with response 'def' 'sub'path("/ghi") { // complete with response 'ghi' 'sub'path("/jkl") { // complete with response 'jkl' } } } } }
Or any other correct way of nesting paths?
Best, zmeda
zmeda source share