Class: Txdb::Handlers::HookHandler

Inherits:
Object
  • Object
show all
Includes:
ResponseHelpers
Defined in:
lib/txdb/handlers/hook_handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ HookHandler

Returns a new instance of HookHandler.



17
18
19
# File 'lib/txdb/handlers/hook_handler.rb', line 17

def initialize(request)
  @request = request
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



15
16
17
# File 'lib/txdb/handlers/hook_handler.rb', line 15

def request
  @request
end

Class Method Details

.handle_request(request) ⇒ Object



8
9
10
# File 'lib/txdb/handlers/hook_handler.rb', line 8

def handle_request(request)
  new(request).handle
end

Instance Method Details

#handleObject



21
22
23
24
25
26
27
# File 'lib/txdb/handlers/hook_handler.rb', line 21

def handle
  return respond_with_error(401, 'Unauthorized') unless authentic_request?
  downloader.download_resource(resource, table, locale)
  respond_with(200, {})
rescue => e
  respond_with_error(500, "Internal server error: #{e.message}", e)
end