Class: Vault::Web

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/vault-tools/web.rb

Overview

Base class for HTTP API services.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.route(verb, action) ⇒ Object

Store the action for logging purposes.



7
8
9
10
# File 'lib/vault-tools/web.rb', line 7

def self.route(verb, action, *)
  condition { @action = action }
  super
end

Instance Method Details

#/Object

Determine if the service is running and responding to requests.

Returns:

  • The following responses may be returned by this method:

    • HTTP 200 OK: Returned if the request was successful.


67
68
69
# File 'lib/vault-tools/web.rb', line 67

head '/' do
  status(200)
end

#/healthObject

Determine if the service is running and responding to requests.

Returns:

  • The following responses may be returned by this method:

    • HTTP 200 OK: Returned if the request was successful with OK in the body.


78
79
80
# File 'lib/vault-tools/web.rb', line 78

get '/health' do
  [200, 'OK']
end

#boomObject

Trigger an internal server error (to test monitoring and paging tools).

Returns:

  • The following responses may be returned by this method:

    • HTTP 500 Internal Server Error: Returned with a traceback in the body.


89
90
91
# File 'lib/vault-tools/web.rb', line 89

get '/boom' do
  raise "An expected error occurred."
end