Jets Controllers run through a set of Rack middlewares. To can see the full list of middleware with the jets middleware command.

Configuring Middleware Stack

You can add, swap, and delete middleware from the Jets stack. Here are some contrived examples:


Jets.application.configure do
  config.middleware.use(new_middleware, args)
  config.middleware.insert_before(existing_middleware, new_middleware, args)
  config.middleware.insert_after(existing_middleware, new_middleware, args)
  config.middleware.use MyMiddleware::Cache, page_cache: false
  config.middleware.swap Rack::Head, MyMiddleware::Head
  config.middleware.delete MyMiddleware

When each middleware class is initialized, it is passed the Jets.application and the args object. For example:

config.middleware.use MyMiddleware::Cache, page_cache: false

Reults in this code:

MyMiddleware::Cache.new(app, page_cache: false)

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub, and contributions are encouraged and welcomed. We love pull requests from you!