Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework with Gzip not working

As you know, play! introduced Gzip encoding in 2.2.0 version.
Unfortunately, after updating project and updating play, it doesn't work.

[error] ...\app\Global.scala:4: object filters is not a member of package play
[error] import play.filters.gzip.GzipFilter
[error]             ^
[error] ...\app\Global.scala:8: not found: type GzipFilter
[error] object Global extends WithFilters(new GzipFilter) with GlobalSettings {
[error]                                       ^
[error] two errors found
[error] (compile:compile) Compilation failed

It doesn't work even if I create project form console play new TEST.

However in C:\play-2.2.0\framework\src\play-filters-helpers\src\main\scala\play\filters\gzip I have both Gzip.scala and GzipFilter.scala.

My \app\Global.scala looks like that:

import play.api._
import play.api.mvc._
import play.api.mvc.Results._
import play.filters.gzip.GzipFilter
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

object Global extends WithFilters(new GzipFilter) with GlobalSettings {
    override def onStart(app: Application) {
        Logger.info("Application has started")
    }

    override def onStop(app: Application) {
        Logger.info("Application shutdown")
    }

    override def onError(request: RequestHeader, ex: Throwable) = Future { InternalServerError("{}") }
    override def onBadRequest(request: RequestHeader, error: String) = Future { BadRequest("{}") }
    override def onHandlerNotFound(request: RequestHeader) = Future { NotFound("{}") }
}

What am I doing wrong? Has anyone made that working?

like image 791
Kamil Lelonek Avatar asked Feb 21 '26 09:02

Kamil Lelonek


1 Answers

In Build.scala, just add "filters" to your app dependencies

val appDependencies = Seq(
  jdbc, cache, filters, ...
)

or, if you are doing it with build.sbt

libraryDependencies ++= Seq(
  jdbc, cache, filters, ...
)
like image 87
Julien D Avatar answered Feb 23 '26 10:02

Julien D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!