Question

I have the following routes defined below in Spray.io. What's really weird is every time I call something like /user/8dsdf974jj it actually runs all three of the following routes. Humorously, I noticed it because I was getting 20 verification emails sent to me at the same time.

pathPrefix("user") {
  pathPrefix(PathElement) { id =>
        path("") {
              get { // code here }
        } ~
        path("verify" / "request") {
              get { // code here }
        } ~
        path("verify" / "confirm") {
              get { // code here }
        }
      }
}

Can someone explain why the path doesn't terminate the routing tree? Thanks for the help.

Was it helpful?

Solution

In short, the problem is that your code runs at route-building time not when the request is actually handled.

This document explain it in longer form: http://spray.io/documentation/spray-routing/advanced-topics/understanding-dsl-structure/

If you look on the mailing list you will find lots of threads about this exact problem which should help you further.

HTH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top