class Marten::Middleware::AssetServing


Allows serving compressed static assets.

This middleware serves the collected assets that are available under the configured assets root (assets.root setting). This assumes that the assets under this folder have been "collected" by using the collectassets management command and that the assets storage being used is the "file system" one (Marten::Core::Storage::FileSystem).

It should also be noted that this middleware will automatically compress served assets using GZip or deflate based on the incoming Accept-Encoding header. The middleware also sets the Cache-Control header and specifies a max-age of 3600s.

Defined in:


Instance Method Summary

Instance methods inherited from class Marten::Middleware

call(request : Marten::HTTP::Request, get_response : Proc(Marten::HTTP::Response)) : Marten::HTTP::Response call, next : Nil | Middleware next, next=(next __arg0 : Nil | Middleware) next=

Instance Method Detail

def call(request : Marten::HTTP::Request, get_response : Proc(Marten::HTTP::Response)) : Marten::HTTP::Response #
Description copied from class Marten::Middleware

Calls the middleware for a given HTTP request and returns a HTTP response.

This method must be implemented by subclasses: it takes a request argument (the current HTTP request) and a get_response proc that allows to get the final response. This proc might actually call the next middleware in the chain of configured middlewares, or the final matched handler. That way, the current middleware have the ability to intercept any incoming request and the associated response, and to modify them if applicable.

[View source]