class Pepito::Handlers::ExtensionsCatalog
Handler
to manage (start, stop, status) the extensions.
Public Instance Methods
Get a list of the currently running adapters. @param _source [Pepito::Source] Source
of the message. Not used. @param _match_data [MatchData] Match Data. Not used. @return [Array<String>]
# File lib/pepito/handlers/extensions_catalog.rb, line 83 def adapters_chat(_source, _match_data) @robot.adapters.keys end
HTTP API List the running adapters. @param _request [Rack::Request] @param response [Rack::Response] @return [void]
# 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
HTTP API List the running handlers and adapters. @param _request [Rack::Request] @param response [Rack::Response] @return [void]
# 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
Get a list of the currently running handlers. @param _source [Pepito::Source] Source
of the message. Not used. @param _match_data [MatchData] Match Data. Not used. @return [Array<String>]
# File lib/pepito/handlers/extensions_catalog.rb, line 75 def handlers_chat(_source, _match_data) @robot.handlers.keys end
HTTP API List the running handlers. @param _request [Rack::Request] @param response [Rack::Response] @return [void]
# 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
Get a list of the currently active http routes. @param _source [Pepito::Source] Source
of the message. Not used. @param _match_data [MatchData] Match Data. Not used. @return [Array<String>]
# File lib/pepito/handlers/extensions_catalog.rb, line 91 def routes_chat(_source, _match_data) api_routes end
HTTP API List the active http routes. @param _request [Rack::Request] @param response [Rack::Response] @return [void]
# 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 the extensions handler. @return [void]
# 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
Private Instance Methods
Get the http routes in the form of an array of strings. @return [Array<String>]
# File lib/pepito/handlers/extensions_catalog.rb, line 99 def api_routes routes = [] @robot.http_api.router.routes.each do |route| routes << route.path_for_generation end routes end