Class: Pepito::Handlers::ExtensionsCatalog
- Inherits:
-
Pepito::Handler
- Object
- Pepito::Handler
- Pepito::Handlers::ExtensionsCatalog
- Defined in:
- lib/pepito/handlers/extensions_catalog.rb
Overview
Handler to manage (start, stop, status) the extensions.
Instance Attribute Summary
Attributes inherited from Pepito::Handler
Instance Method Summary collapse
-
#adapters_chat(_source, _match_data) ⇒ Array<String>
Get a list of the currently running adapters.
-
#adapters_web(_request, response) ⇒ void
HTTP API List the running adapters.
-
#extensions_web(_request, response) ⇒ void
HTTP API List the running handlers and adapters.
-
#handlers_chat(_source, _match_data) ⇒ Array<String>
Get a list of the currently running handlers.
-
#handlers_web(_request, response) ⇒ void
HTTP API List the running handlers.
-
#routes_chat(_source, _match_data) ⇒ Array<String>
Get a list of the currently active http routes.
-
#routes_web(_request, response) ⇒ void
HTTP API List the active http routes.
-
#run ⇒ void
Run the extensions handler.
Methods inherited from Pepito::Handler
Methods included from Pepito::Handler::ChatRouter
Methods included from Pepito::Handler::HTTPRouter
Constructor Details
This class inherits a constructor from Pepito::Handler
Instance Method Details
#adapters_chat(_source, _match_data) ⇒ Array<String>
Get a list of the currently running adapters.
83 84 85 |
# File 'lib/pepito/handlers/extensions_catalog.rb', line 83 def adapters_chat(_source, _match_data) @robot.adapters.keys end |
#adapters_web(_request, response) ⇒ void
This method returns an undefined value.
HTTP API List the running adapters.
51 52 53 54 55 56 57 |
# File 'lib/pepito/handlers/extensions_catalog.rb', line 51 def adapters_web(_request, response) response.headers['Content-Type'] = 'application/json' json = MultiJson.dump( adapters: @robot.adapters.keys ) response.write(json) end |
#extensions_web(_request, response) ⇒ void
This method returns an undefined value.
HTTP API List the running handlers and adapters.
26 27 28 29 30 31 32 33 |
# File 'lib/pepito/handlers/extensions_catalog.rb', line 26 def extensions_web(_request, response) response.headers['Content-Type'] = 'application/json' json = MultiJson.dump( handlers: @robot.handlers.keys, adapters: @robot.adapters.keys ) response.write(json) end |
#handlers_chat(_source, _match_data) ⇒ Array<String>
Get a list of the currently running handlers.
75 76 77 |
# File 'lib/pepito/handlers/extensions_catalog.rb', line 75 def handlers_chat(_source, _match_data) @robot.handlers.keys end |
#handlers_web(_request, response) ⇒ void
This method returns an undefined value.
HTTP API List the running handlers.
39 40 41 42 43 44 45 |
# File 'lib/pepito/handlers/extensions_catalog.rb', line 39 def handlers_web(_request, response) response.headers['Content-Type'] = 'application/json' json = MultiJson.dump( handlers: @robot.handlers.keys ) response.write(json) end |
#routes_chat(_source, _match_data) ⇒ Array<String>
Get a list of the currently active http routes.
91 92 93 |
# File 'lib/pepito/handlers/extensions_catalog.rb', line 91 def routes_chat(_source, _match_data) api_routes end |
#routes_web(_request, response) ⇒ void
This method returns an undefined value.
HTTP API List the active http routes.
63 64 65 66 67 68 69 |
# File 'lib/pepito/handlers/extensions_catalog.rb', line 63 def routes_web(_request, response) response.headers['Content-Type'] = 'application/json' json = MultiJson.dump( routes: api_routes ) response.write(json) end |
#run ⇒ void
This method returns an undefined value.
Run the extensions handler.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pepito/handlers/extensions_catalog.rb', line 11 def run http_route('GET', '/extensions', :extensions_web) http_route('GET', '/handlers', :handlers_web) http_route('GET', '/adapters', :adapters_web) http_route('GET', '/routes', :routes_web) chat_route(/^handlers list$/i, :handlers_chat, command: true, help: 'handlers list -> show list of active handlers') chat_route(/^adapters list$/i, :adapters_chat, command: true, help: 'adapters list -> show list of active adapters') chat_route(/^routes list$/i, :routes_chat, command: true, help: 'routes list -> show list of active api routes') end |