RoR Grape API | How to invoke an endpoint in one API from another?

156 views Asked by At

I'm using Grape API with Ruby on Rails. I would like to invoke a POST endpoint in Api::A from an endpoint in Api::B, where both are mounted under the Api class.

class Api < Grape::API
  mount Api::A
  mount Api::B
end

class Api::Base < Grape::API
  # common functionality
end

# contains endpoints pertaining to entity A
class Api::A < Api::Base
  namespace :a do
    params do
     ...
    end
    post '' begin
      ...
    end
  end
end

# contains endpoints pertaining to entity B
class Api::B < Api::Base
  namespace :b do
    params do
     ...
    end
    post '' begin
      # How do I directly invoke Api::A's POST endpoint?
    end
  end
end
0

There are 0 answers