Module: Roda::RodaPlugins::RunAppendSlash

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

Overview

The run_append_slash plugin makes r.run use / as the PATH_INFO when calling the rack application if PATH_INFO would be empty. Example:

route do |r|
r.on "a" do
  r.run App
end
end

# without run_append_slash: 
# GET /a => App gets "" as PATH_INFO
# GET /a/ => App gets "/" as PATH_INFO

# with run_append_slash: 
# GET /a => App gets "/" as PATH_INFO
# GET /a/ => App gets "/" as PATH_INFO

Defined Under Namespace

Modules: RequestMethods

Class Method Summary collapse

Class Method Details

.configure(app, opts = OPTS) ⇒ Object

Set plugin specific options. Options: :use_redirects :: Whether to issue a redirect to the path with the slash appended, instead of calling the app directly with the trailing slash. Note that if the current path starts with //, it will call the app directly instead of redirecting.



30
31
32
# File 'lib/roda/plugins/run_append_slash.rb', line 30

def self.configure(app, opts=OPTS)
  app.opts[:run_append_slash_redirect] = !!opts[:use_redirects]
end