Class: Upman::Extensions::Index::Servlet

Inherits:
Server::BaseServlet
  • Object
show all
Includes:
Utils::Dynload
Defined in:
lib/upman/extensions/index.rb

Instance Attribute Summary

Attributes inherited from Server::BaseServlet

#error_msg, #query, #response

Instance Method Summary collapse

Methods included from Utils::Dynload

#dynload

Methods inherited from Server::BaseServlet

#bad_request, #get_param, #initialize, #is_authenticated, #not_authorized, #ok

Methods included from Utils::Helper

#fail, #info, #success, #warn

Constructor Details

This class inherits a constructor from Upman::Server::BaseServlet

Instance Method Details

#do_GET(request, response) ⇒ Object

rubocop:disable Naming/MethodName



15
16
17
18
19
20
# File 'lib/upman/extensions/index.rb', line 15

def do_GET(request, response)
  # rubocop:enable Naming/MethodName

  super(request, response)
  response = ok(response, perform_action(request))
end

#perform_action(request) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/upman/extensions/index.rb', line 22

def perform_action(request)
  endpoints = []
  hostname = request.request_uri.to_s.sub(request.script_name, '')
  ::Upman::Core::Config.daemon[:extensions].each do |extension|
    ext_obj = dynload("Upman::Extensions::#{extension.split('_').map(&:capitalize).join('')}")
    endpoints.append "#{hostname}/#{ext_obj ::REQUEST_PATH}.do"
  end
  "{\"message\": \"upman-#{::Upman::Version::VERSION} - Daemon is running\", \"endpoints\": #{endpoints.to_json}}"
end