Like @johanandren suggested, I replaced all except the last path
with pathPrefix
.
And the code now works!
The Routes code now looks like below:
(Disclaimer: Llama or ChatGPT could NOT have pulled off this beautiful solution in a million years!!! God given natural intuition still rocks! 😎😎😎👌👌👌)
val schoolRoutes: Route =
pathPrefix("littlerock") {
concat(
pathPrefix("admins") {
concat(
pathEnd {
concat(
get {
complete("District administrators.")
})
})
},
pathPrefix("schools") {
concat(
pathPrefix(Segment) { name =>
concat(
pathEnd {
get {
rejectEmptyResponse {
complete("A school's details.")
}
}
},
pathPrefix("students") {
concat(
pathEnd {
get {
rejectEmptyResponse {
complete("All students")
}
}
},
pathPrefix(Segment) { studentName =>
concat(
pathEnd {
get {
rejectEmptyResponse {
complete("A student's details")
}
}},
pathPrefix("classmates") {
concat(
pathEnd {
get {
rejectEmptyResponse {
complete("A student's classmates.")
}
}
},
path(Segment) { classmateName =>
concat(
get {
rejectEmptyResponse {
complete("A classmate's details.")
}
})
}
)
}
)
}
)
}
)
})
}
)}