Since Spray.io is defining content types at a low-level, how do I simply reference the content-type of the incoming request?
Here's a short example where an image is PUT.
put {
entity(as[Array[Byte]]) { data =>
complete{
val guid = Image.getGuid(id)
val fileExtension = // match a file extension to content-type here
val key = "%s-%s.%s" format (id, guid, fileExtension )
val o = new Image(key, contentType, data)
Image.store(o)
val m = Map("path" -> "/client/%s/img/%s.%s" format (id, guid, fileExtension))
HttpResponse(OK, generate(m))
}
}
}
Given the code above, what's an easy way to extract the content type? I can simply use that to pattern-match to an appropriate fileExtension
. Thanks for your help.