Skip to content

Instantly share code, notes, and snippets.

@amencke
Last active July 13, 2021 04:49
Show Gist options
  • Save amencke/9b3a45d29c5958977ced1cf3881c51a6 to your computer and use it in GitHub Desktop.
Save amencke/9b3a45d29c5958977ced1cf3881c51a6 to your computer and use it in GitHub Desktop.
lazy val conversationRoutes: Route = {
concat(
pathPrefix(version / "conversation" / LongNumber) { conversationID =>
post {
entity(as[PostMessageRequest]) {
pmr =>
val maybeSessionGranted: Future[SessionEvent] =
getSession(conversationID, pmr.userID)
onComplete(maybeSessionGranted) {
case Success(SessionGranted(session)) =>
postMessage(conversationID, pmr.userID, pmr.message)(session)
complete(OK, PostMessageResponse(pmr.message))
case Failure(ex) =>
complete(InternalServerError -> ex)
case _ => complete(InternalServerError, "An unknown error occurred")
}
}
}
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment