Skip to content

Settings

Lars Olsson edited this page Dec 14, 2017 · 6 revisions

Settings

You can apply settings in Racket in two ways.

a) Globally

settings = { setting_1: 'value_1', setting_2: 'value_2' } 

run Racket::Application.using(settings)

b) For a specific controller

class MyController
  setting :setting_1, 'value_1'
  setting :setting_2, 'value_2'
end

❗ Use symbols for setting keys, setting values may be any ruby object.

All global settings are inherited by the controllers, so if you want to have a set of default settings but want to have other settings on a specific controller you can combine the methods above.

Available settings

This is the current list of built-in settings that Racket understands. You are not limited to these, you can add custom settings you like (both globally and on a per-controller-basis) by just using a settings name that does not appear in the list below.

Name Description Default value Applicable in controller context
controller_dir Root directory for controller files root_dir/controllers no
default_action Default action to call if no action was specified :index yes
default_content_type Default content type text/html no
default_controller_helpers Controller helpers to load by default [:routing, :view] no
default_layout Default layout (a symbol, a string a proc or nil) nil yes
default_view Default view (a symbol, a string a proc or nil) nil yes
helper_dir Root directory for helpers root_dir/helpers no
layout_dir Root directory for layouts root_dir/layouts no
logger Application logger Logger.new($stdout) no
middleware Array of Rack middlewares. Depends on runtime mode, but unless you override this setting you get at least Rack::ContentLength and Rack::ContentType. no
mode Runtime mode, either :dev or :live :live no
plugins Array of Racket lugins to load [] no
public_dir Root directory for static files root_dir/public no
root_dir Root directory Dir.pwd no
session_handler Racket session handler An instance of Rack::Session::Cookie no
view_dir Root directory for views root_dir/views yes
warmup_urls Array of URLs to visit on application start [] no
Clone this wiki locally