Class: Nagira::ApiHelpController
- Inherits:
-
Object
- Object
- Nagira::ApiHelpController
- Defined in:
- app/controllers/api_help_controller.rb
Overview
Parse routes, exposed by Sinatra and build human readable list of API endpoints.
Class Method Summary collapse
-
.get ⇒ Object
Get all routes that Nagira provides.
Class Method Details
.get ⇒ Object
Get all routes that Nagira provides.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/api_help_controller.rb', line 7 def self.get api = { } param_regex = Regexp.new '\(\[\^\\\\\/\?\#\]\+\)' Nagira.routes.keys.each do |method| api[method] ||= [] Nagira.routes[method].each do |r| path = r[0].inspect[3..-3] r[1].each do |parm| path.sub!(param_regex,":#{parm}") end path.gsub!('\\','') api[method] << path unless path.empty? end end api end |