Module: Sinatra::Hancock::Defaults::Helpers

Defined in:
lib/sinatra/hancock/defaults.rb

Instance Method Summary collapse

Instance Method Details

#absolute_url(suffix = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/sinatra/hancock/defaults.rb', line 9

def absolute_url(suffix = nil)
  port_part = case request.scheme
              when "http"
                request.port == 80 ? "" : ":#{request.port}"
              when "https"
                request.port == 443 ? "" : ":#{request.port}"
              end
  "#{request.scheme}://#{request.host}#{port_part}#{suffix}"
end

#forbidden!Object



5
6
7
# File 'lib/sinatra/hancock/defaults.rb', line 5

def forbidden!
  throw :halt, [403, 'Forbidden']
end