module Roda::RodaPlugins::RequestHeaders

  1. lib/roda/plugins/request_headers.rb

The request_headers plugin provides access to headers sent in the request in a more natural way than directly accessing the env hash.

In practise this means you don't need to uppercase, convert dashes to underscores, or add a HTTP_ prefix.

For example, to access a header called X-My-Header you would previously need to do:

r.env['HTTP_X_MY_HEADER']

But with this plugin you can now say:

r.headers['X-My-Header']

The name is actually case-insensitive so x-my-header will work as well.

Example:

plugin :request_headers