How to catch URL with slash in spray mode?

The spray is very simple, but I have problems understanding routing. It looks like a dog that sometimes gets a bone, often not. What am I missing?

Is there a way to see which routes Spray tries and why it refuses certain ones? That would essentially solve it. logRequestBelow, I just show the request, but it does not say why the path could not match it.

  ...
  (get & logRequest("SAY AAA:")) {
    path("results") {    
        complete("results")
    } ~
    path("results/") {    // does not work
        complete("results/")
    } ~
    complete("fallback")
  }

Leads to:

"results/aaa" -> fallback
"results/" -> fallback
"results" -> results

How can I capture a case "results/"?

Slightly similar issues: 19556196

Application: I got it to work with path("results" / ""). Why "results/"doesn’t work?

+4
source share
1 answer

Well, it seems the right way:

    (pathPrefix("results") & pathEndOrSingleSlash) {
      complete( "results[/]" )
    }

results, results/, .

pathEndOrSingleSlash doc

+5

All Articles