Module: Hcheck::ApplicationHelpers::Responders

Included in:
SinatraBase
Defined in:
lib/hcheck/application/helpers/responders.rb

Overview

Sinatra app controller helpers

Class Method Summary collapse

Class Method Details

.h_statusObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/hcheck/application/helpers/responders.rb', line 7

def h_status
  authenticate!(params) if secured_access_enabled?

  @status = Hcheck.status

  if @status.find { |s| s[:status] == 'bad' }
    status 503
  else
    status 200
  end

  haml :index
rescue Hcheck::Errors::InvalidAuthentication, Hcheck::Errors::IncompleteAuthSetup => e
  status 401
  @msg = e.message

  haml :error
end

.respond_with(message, status_code, view) ⇒ Object



26
27
28
29
30
31
# File 'lib/hcheck/application/helpers/responders.rb', line 26

def respond_with(message, status_code, view)
  status status_code
  @msg = message

  haml view
end