I gave this custom directive a quick unit test and it seems to work:
def pathEndOr(p: String) =
pathEnd.hmap(true :: _) | path(p).hmap(false :: _)
You can use it in you example like so:
...
pathEndOr("summary") { isPathEnd =>
parameters(...).as(Query) { query =>
onSuccess(model ? query) {
case MyResponse(list) =>
// at this point I would like to know if I hit pathEnd or
// path(summary) so I can complete with summary or full response.
if (isPathEnd)
complete(OK, list)
else
complete(OK, list map (_.toSummary))
}
}
}
...