Module: Roda::RodaPlugins::DefaultStatus

Defined in:
lib/roda/plugins/default_status.rb

Overview

The default_status plugin accepts a block which should return a response status integer. This integer will be used as the default response status (usually 200) if the body has been written to, and you have not explicitly set a response status. The block given to the block is instance_execed in the context of the response.

Example:

# Use 201 default response status for all requests
plugin :default_status do
  201
end

Defined Under Namespace

Modules: ResponseMethods

Class Method Summary collapse

Class Method Details

.configure(app, &block) ⇒ Object

Raises:



20
21
22
23
# File 'lib/roda/plugins/default_status.rb', line 20

def self.configure(app, &block)
  raise RodaError, "default_status plugin requires a block" unless block
  app.opts[:default_status] = block
end