Hi Johannes,
Thanks for your reply, then I would prefer to re-structure my routes to accommodate the new changes than to hack around them.
Could you assist then, because I was always under the impression run the most specific first, down to the least specific. And following that thought I structure my routes like the following (pseudo as I am on a train right now).
Here you can see deeper structures first, and when the nested user-role or user-space structure is completed, I then handle the less specific paths until I've 'walked' the way back up to /user. At that point the next 'root' path will begin for that domain object, perhaps roles or something else which will follow a similar structure.
pathPrefix("users") {
pathPrefix(Segment) { userId =>
pathPrefix("roles") {
pathPrefix(Segment) { roleId =>
put { complete { (getSecurityActor ? CreateUserRoleLink(Join(userId, roleId))).mapTo[Either[Failure, Success]] } } ~
delete { complete { (getSecurityActor ? RemoveUserRoleLink(Join(userId, roleId))).mapTo[Either[Failure, Success]] } }
}
} ~
pathPrefix("spaces") {
pathPrefix(Segment) { spaceId =>
put { complete { (getSecurityActor ? CreateUserSpaceLink(Join(userId, spaceId))).mapTo[Either[Failure, Success]] } } ~
delete { complete { (getSecurityActor ? RemoveUserSpaceLink(Join(userId, spaceId))).mapTo[Either[Failure, Success]] } }
}
} ~
/* here you can see how I handle a less specific path, as the Segment userId has already been declared and it's sub-paths handled
* I wanted to handle just that segment here, how would I then capture paths that 'terminate' at this level? */
path("") {
get { complete { (getSecurityActor ? GetUser(userId)).mapTo[Option[User]] } }
put { handleWith { model: User => (getSecurityActor ? UpdateUser(userId, model)).mapTo[Either[Failure, Success]] } }
}
} ~
/* The same goes for the following situation, I have already finished with the userId segment, and now want to
* handle searches and posts at the root /users path, how can I now handle these paths */
model => complete { (getSecurityActor ? UserSearch(model)).mapTo[SearchResult[User]] }
} } ~
post { handleWith { model: User => (getSecurityActor ? CreateUser(model)).mapTo[Either[Failure, Success]] } }
}
}
I also want to thank you for your teams support, as usual top-class fantastic effort. Congratulations on such an excellent library and on joining the typesafe team. Looking forward to the future!!
Cheers, Aaron