Module: Brut::SinatraHelpers

Defined in:
lib/brut/sinatra_helpers.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(sinatra_app) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/brut/sinatra_helpers.rb', line 3

def self.included(sinatra_app)
  sinatra_app.extend(ClassMethods)

  sinatra_app.set :logging, false
  sinatra_app.set :public_folder, Brut.container.public_root_dir
  sinatra_app.path("/__brut/csp-reporting",method: :post)
  sinatra_app.path("/__brut/locale_detection",method: :post)
  sinatra_app.path("/__brut/instrumentation",method: :get)
  sinatra_app.set :host_authorization, permitted_hosts: Brut.container.permitted_hosts
  sinatra_app.set :show_exceptions, false
end

Instance Method Details

#render_html(component_or_page_instance) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/brut/sinatra_helpers.rb', line 16

def render_html(component_or_page_instance)
  result = component_or_page_instance.render
  case result
  in Brut::FrontEnd::HttpStatus => http_status
    http_status.to_i
  else
    result
  end
end