com.lightbend.lagom.scaladsl.server
A service call that can handle headers.
A service call that can handle headers.
This exists as a convenience function for implementing service calls that handle the request and response headers.
Factory for creating a ServerServiceCall.
Factory for creating a ServerServiceCall.
This exists as a convenience function for implementing service calls that need to be composed with other calls that handle headers.
Compose a server service call.
Compose a server service call.
This is useful for implementing service call composition. For example:
def authenticated[Request, Response](
authenticatedServiceCall: String => ServerServiceCall[Request, Response]
): ServerServiceCall[Request, Response] = {
ServerServiceCall.compose { requestHeader =>
// Get the logged in user ID val userId = requestHeader.principal.getOrElse { throw new NotAuthenticated("Not authenticated") }.getName
// Pass the user id to the composed service call
authenticatedServiceCall(userId)
}
}
The block that will do the composition.
A service call.
Compose a header service call asynchronously.
Compose a header service call asynchronously.
This is useful for implementing service call composition. For example:
def authenticated[Request, Response](
authenticatedServiceCall: String => ServerServiceCall[Request, Response]
): ServerServiceCall[Request, Response] = {
ServerServiceCall.composeAsync { requestHeader =>
// Get the logged in user ID val userId = requestHeader.principal.getOrElse { throw new NotAuthenticated("Not authenticated") }.getName
// Load the user from the user service val userFuture: Future[User] = userService.loadUser(userId)
// Pass the user to the composed service call
userFuture.map(user => authenticatedServiceCall(user))
}
}
The block that will do the composition.
A service call.