Class: RnStack::ApiController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RnStack::ApiController
- Defined in:
- app/controllers/rn_stack/api_controller.rb
Instance Method Summary collapse
Instance Method Details
#handle ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/rn_stack/api_controller.rb', line 5 def handle # Dynamically load and call the API handler # e.g., app/api/users.rb -> constant Users handler_class = params[:api_path].camelize.constantize render json: handler_class.call(request) rescue NameError => e render json: { error: "Handler not found", details: e. }, status: :not_found rescue StandardError => e render json: { error: "API Error", details: e. }, status: :internal_server_error end |