Skip to content

Instantly share code, notes, and snippets.

@faisal00813
Last active November 21, 2017 06:55
Show Gist options
  • Save faisal00813/4d37f86d9c8503d9b823cd9a51108f34 to your computer and use it in GitHub Desktop.
Save faisal00813/4d37f86d9c8503d9b823cd9a51108f34 to your computer and use it in GitHub Desktop.
Akka-http request handler for application/octet-stream
pathPrefix("user") {
path("msgPackTest") {
post {
extractRequest {
req =>
println(req.headers)
req.entity match {
case strict: HttpEntity.Strict =>
val resp = req.entity.dataBytes.runFold(ByteString.empty) { case (acc, b) => acc ++ b }
.map(x=> processMsgPackMsg(x.compact.toArray[Byte]))
complete {
resp
}
case _ =>
complete("Ooops, request entity is not strict!")
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment