play-brotli-filter

A brotli filter for the play framework

License

License

GroupId

GroupId

com.gu
ArtifactId

ArtifactId

play-brotli-filter_2.12
Last Version

Last Version

0.5
Release Date

Release Date

Type

Type

jar
Description

Description

play-brotli-filter
A brotli filter for the play framework
Project URL

Project URL

https://github.com/guardian/play-brotli-filter
Project Organization

Project Organization

com.gu
Source Code Management

Source Code Management

https://github.com/guardian/play-brotli-filter

Download play-brotli-filter_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.gu/play-brotli-filter_2.12/ -->
<dependency>
    <groupId>com.gu</groupId>
    <artifactId>play-brotli-filter_2.12</artifactId>
    <version>0.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.gu/play-brotli-filter_2.12/
implementation 'com.gu:play-brotli-filter_2.12:0.5'
// https://jarcasting.com/artifacts/com.gu/play-brotli-filter_2.12/
implementation ("com.gu:play-brotli-filter_2.12:0.5")
'com.gu:play-brotli-filter_2.12:jar:0.5'
<dependency org="com.gu" name="play-brotli-filter_2.12" rev="0.5">
  <artifact name="play-brotli-filter_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gu', module='play-brotli-filter_2.12', version='0.5')
)
libraryDependencies += "com.gu" % "play-brotli-filter_2.12" % "0.5"
[com.gu/play-brotli-filter_2.12 "0.5"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.3
org.meteogroup.jbrotli » jbrotli jar 0.5.0

provided (2)

Group / Artifact Type Version
org.meteogroup.jbrotli » jbrotli-native-darwin-x86-amd64 jar 0.5.0
com.typesafe.play : play_2.12 jar 2.6.3

test (2)

Group / Artifact Type Version
com.typesafe.play : filters-helpers_2.12 jar 2.6.3
com.typesafe.play : play-specs2_2.12 jar 2.6.3

Project Modules

There are no modules declared in this project.

Brotli filter for play

Maven Central Build Status License

A Brotli filter for the playframework

Install

Add jbrotli bintray as a resolver:

resolvers += "JBrotli Bintray Repository" at "https://dl.bintray.com/nitram509/jbrotli/"

Add play-brotli-filter as a dependency:

libraryDependencies ++= Seq(
 "com.gu" %% "play-brotli-filter" % "0.1",
 "org.meteogroup.jbrotli" % brotliNativeArtefact % "0.5.0",
)

brotliNativeArtefact is dependent of your target platform and can not be resolved transparently as sbt does not support activating maven profile (as far as I am aware).

Below is a workaround that should allow to have the correct artefact name depending on your platform:

val brotliNativeArtefact = {

  val osName = System.getProperty("os.name").toLowerCase
  val osArch = System.getProperty("os.arch").toLowerCase
  
  val family = if (osName.startsWith("linux")) {
    "linux"
    } else if (osName.startsWith("mac os x") || osName.startsWith("darwin")) {
      "darwin"
    } else {
      "win32"
  }

  val arch = if (family == "darwin") {
      "x86-amd64"
    } else if (osArch == "i386" || osArch == "i486" || osArch == "i586" || osArch == "i686") {
      "x86"
    } else if (osArch == "amd64" || osArch == "x86-64" || osArch == "x64") {
      "x86-amd64"
    } else if (family == "linux" && osArch.startsWith("arm")) {
      "arm32-vfp-hflt"
  }

  s"jbrotli-native-$family-$arch"
}

Configure

Currently the only parameter you can configure is quality, which defaults to 5.

play.filters {

  # Brotli filter configuration
  brotli {

    # The compression-speed vs compression-density tradeoffs. The higher the quality, the slower the compression. Range is 0 to 11
    quality = 5

  }
}
com.gu

The Guardian

The source code of the world's leading liberal voice

Versions

Version
0.5
0.4