class Lucky::StaticCompressionHandler

Overview

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"),
  # ...
]

Included Modules

Defined in:

lucky/static_compression_handler.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(public_dir : String, file_ext : String = "gz", content_encoding : String = "gzip") #

[View source]

Instance Method Detail

def call(context) #

[View source]