class

Lucky::StaticCompressionHandler

Inherits HTTP::Handler < Reference < Object

Middleware that serves static files that have been pre-compressed. There can be multiple instances and the first in the middleware stack will take precedence. For example, if you want to serve brotli compressed assets for browsers that support it and serve gzip assets for those that don't you would do something like this in your middleware in src/app_server.cr:

[
  # ...
  Lucky::StaticCompressionHandler.new("./public", file_ext: "br", content_encoding: "br"),
  Lucky::StaticCompressionHandler.new("./public", file_ext: "gz", content_encoding: "gzip"),
  # ...
]

Constructors

new(public_dir : String, file_ext : String = "gz", content_encoding : String = "gzip")
Source

Instance methods