module Roda::RodaPlugins::RunHandler

  1. lib/roda/plugins/run_handler.rb

The run_handler plugin allows to take a block, which is yielded the rack response array, before it returns it as a response.

Additionally, also takes a options hash, and you can provide a not_found: :pass option to keep routing normally if the rack app returns a 404 response.

plugin :run_handler

route do |r|
  r.on 'a' do
    # Keep running code if RackAppFoo doesn't return a result RackAppFoo, not_found: :pass

    # Change response status codes before returning. do |response|
      response[0] = 200 if response[0] == 201