Created
August 7, 2018 14:51
-
-
Save markoutso/b7abd5102ec63530174a677b8084aae4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.http.scaladsl.coding.Gzip | |
import akka.http.scaladsl.model._ | |
object GzipBinEncoder extends Gzip(GzipBinEncoderFilter) | |
object GzipBinEncoderFilter extends (HttpMessage => Boolean) { | |
override def apply(message: HttpMessage): Boolean = | |
message match { | |
case req: HttpRequest ⇒ req.entity.contentType.mediaType.isCompressible | |
case res@HttpResponse(status, _, _, _) => | |
val mediaType = res.entity.contentType.mediaType | |
(mediaType == MediaTypes.`application/octet-stream` || mediaType.isCompressible) && status.allowsEntity | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment