Hi,
I found a very weird behavior. I am using 1.3.3
In the code below, I have three line under noop ~ get with each grouped in either A or B.
If we choose group A the output is
but with the another group we get
It sounds to me although they are of the same abstraction Directive the effect on routing order is different in a way group A evaluates the inner route lazily and the other does eagerly. How could you explain this?
I found this behavior while I am doing an experiment to solve my problem about unexpected routing behavior. My expectation is the matching is done from the forefront and enter the inner route immediately once it matches the "options" without evaluating anything behind. So I expect the behavior of extract as the noop.
class SprayRoutingTest extends FunSuite with ScalatestRouteTest with HttpService {
def actorRefFactory = system
val route = TestRouter().route
test("Options") {
println("Options")
Options("/") ~> route ~> check {
assert(status === StatusCodes.Forbidden)
}
}
test("Get") {
println("Get")
Get("/") ~> route ~> check {
assert(status === StatusCodes.OK)
}
}
}
case class TestRouter() extends SimpleRoutingApp {
val route =
options {
complete(StatusCodes.Forbidden)
} ~ noop {
get {
extract(_.request) { req => // (A)
//provide(0) { n => // (B)
//noop { // (B)
println("hoge")
complete(StatusCodes.OK)
}
}
}
}
- Akira