jeudi 29 septembre 2016

How to add single method to handle multiple routes

my rails application is a proxy server for some rest API services It means all the request for the rest server is routing through my rails app. I have defined all require routes in my routes.rb file and I have written different methods for each routes in my controller. So instead of different methods for each route I want a single method in my controller where I can check the request.fullpath and based on request parameters redirect it to appropriate rest service call

Here is my routes look like

  get '/lookup/location/search', to: 'ticketing#lookup_location_search'
  get '/lookup/company/search', to: 'ticketing#lookup_company_search'
  get '/lookup/assignmentGroup/search', to: 'ticketing#lookup_assignment_group_search'
  get '/lookup/ci/search', to: 'ticketing#lookup_ci_search'
  get '/lookup/user/search', to: 'ticketing#lookup_user_search'  

For each route there is a separate method exist in controller instead of that i want a single method which would further call correct rest URL based on request parameters

Aucun commentaire:

Enregistrer un commentaire