I have following code in Spray to parse the REST service called by user:
val route = {
pathPrefix("v0") {
pathPrefix("pets") {
pathEndOrSingleSlash {
pathEnd {
get {
complete("/v0/pets")
}
} ~
get {
complete("/v0/pets/")
}
} ~
parameters('id ?) {
id =>
get {
complete("/v0/pets?id=" + id)
}
}
}
}
}
The problem is that it is not behaving as expected. I am expecting following behaviour from the code:
http://127.0.0.1/v0/pets => /v0/pets
http://127.0.0.1/v0/pets/ => /v0/pets/
http://127.0.0.1/v0/pets?id=1234 = > /v0/pets?id=Some(1234)
But, I am getting following results for the queries:
http://127.0.0.1/v0/pets => /v0/pets
http://127.0.0.1/v0/pets/ => /v0/pets
http://127.0.0.1/v0/pets?id=1234 => /v0/pets