Anyone have any suggestions? Thanks!
On 07/03/17 22:32, Alan Burlison wrote:
I have an Akka HTTP route for a REST API that first checks the base path,
then checks the user authentication is valid, adds some custom headers and
extracts the base URI before processing the sub-routes. However if the URL
doesn't match any of the sub-routes, request processing "rolls back" to the
authentication step and I get an incorrect message about authentication
failing.
I've wrapped the sub-route processing in Route.seal and that
means that I now get a "Not Found" for nonexistent paths, as
required. However the documentation says that Route.seal shouldn't
really be needed for application code. Is this a valid use of
Route.seal, or is there a better way to prevent route processing from
"rolling back" past a specified point?
def route: Route = {
pathPrefix("rest" / "v1") {
// If the request authenticates successfully, add the custom headers to the
response
// and extract the base URI we were called with.
(combinedAuth & respondWithHeaders(versionHeaders) & baseUri ) { (sess,
baseUri) => {
// Process valid sub-routes, seal the route so we don't roll back past
this point.
Route.seal(concat(
pathEndOrSingleSlash { topRoute(sess, baseUri) },
pathPrefix("users") { userRoute(sess, baseUri) }
))}
}
}
}
--
Alan Burlison
--
--
Read the docs: http://akka.io/docs/
Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.