This might just be a documentation issue. I’ve googled, I’ve search the Akka HTTP docs, and I’ve poked through the code.
A pointer—or code—would be awesome.
I have a String MIME type (such as “application/jar”). I want to create a ContentType for use in a response. I only care about a binary type, as this mapping is for a download only.
I’m stuck with the Java API. (Don’t ask.) I can easily create a mapping from a String to a MediaType. I cannot, for the life of me, figure out how—in Java—to make the final leap from a MediaType to a ContentType.
Is this even possible, without resorting to the Scala API? My client would prefer that there be no Scala in this server.
Ah, you’re awesome Josep
I was looking into this from the pessimistic angle and found that we do not have a 1:1 mirror of the following Scala DSL style:
private val custom: MediaType.Binary = MediaType.customBinary("application", "wat", MediaType.Compressible)
private val binary = ContentType(custom)
println(s"binary = ${binary}")
I wondered why I missed it. Then, I determined that I was using Akka HTTP 10.0.11, which doesn’t have ContentTypes.parse(). I had drilled into ContentTypes via the IDE.