module Roda::RodaPlugins::NotFound

  1. lib/roda/plugins/not_found.rb

The not_found plugin adds a not_found class method which sets a block that is called whenever a 404 response with an empty body would be returned. The usual use case for this is the desire for nice error pages if the page is not found.

You can provide the block with the plugin call:

plugin :not_found do
  "Where did it go?"
end

Or later via a separate call to not_found:

plugin :not_found

not_found do
  "Where did it go?"
end

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

This plugin is now a wrapper around the status_handler plugin and still exists mainly for backward compatibility.

Methods

Public Class

  1. configure
  2. load_dependencies

Public Class methods

configure (app, &block)

If a block is given, install the block as the not_found handler.

[show source]
# File lib/roda/plugins/not_found.rb, line 38
def self.configure(app, &block)
  if block
    app.not_found(&block)
  end
end
load_dependencies (app)

Require the status_handler plugin

[show source]
# File lib/roda/plugins/not_found.rb, line 33
def self.load_dependencies(app)
  app.plugin :status_handler
end