Sha256: d94d7cfdc03031201ce096f0ac959e24daa0e8669b2864233f018680287c911e
Contents?: true
Size: 1.09 KB
Versions: 16
Compression:
Stored size: 1.09 KB
Contents
class ForestLiana::Router def call(env) params = env['action_dispatch.request.path_parameters'] collection_name = params[:collection] resource = ForestLiana::SchemaUtils.find_model_from_collection_name(collection_name) begin component_prefix = ForestLiana.component_prefix(resource) controller_name = "#{component_prefix}Controller" controller = "ForestLiana::UserSpace::#{controller_name}".constantize action = nil case env['REQUEST_METHOD'] when 'GET' if params[:id] action = 'show' elsif env['PATH_INFO'] == "/#{collection_name}/count" action = 'count' else action = 'index' end when 'PUT' action = 'update' when 'POST' action = 'create' when 'DELETE' action = 'destroy' end controller.action(action.to_sym).call(env) rescue NoMethodError => exception FOREST_LOGGER.error "Routing error: #{exception}\n#{exception.backtrace.join("\n\t")}" ForestLiana::ApplicationController.action(:route_not_found).call(env) end end end
Version data entries
16 entries across 16 versions & 1 rubygems