module Roda::RodaPlugins::StatusHandler

  1. lib/roda/plugins/status_handler.rb

The status_handler plugin adds a status_handler method which sets a block that is called whenever a response with the relevant response code with an empty body would be returned.

This plugin does not support providing the blocks with the plugin call; you must provide them to status_handler calls afterwards:

plugin :status_handler

status_handler(403) do
  "You are forbidden from seeing that!"
status_handler(404) do
  "Where did it go?"

Before a block is called, any existing headers on the response will be cleared. So if you want to be sure the headers are set even in your block, you need to reset them in the block.


Public Class

  1. configure

Public Class methods

[show source]
   # File lib/roda/plugins/status_handler.rb
26 def self.configure(app)
27   app.opts[:status_handler] ||= {}
28 end