Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount of another Grape API on a path doesn't work #60

Closed
mbleigh opened this issue Sep 2, 2011 · 4 comments
Closed

Mount of another Grape API on a path doesn't work #60

mbleigh opened this issue Sep 2, 2011 · 4 comments

Comments

@mbleigh
Copy link
Contributor

mbleigh commented Sep 2, 2011

A Grape API should be able to mount other Rack applications inside of it. In addition, it should be able to mount another API and that API will inherit the other API's settings.

class UsersAPI < Grape::API
  get '/:id' do
    # ...
  end
end

class MyAPI
  version :v1
  mount UsersAPI => '/users'
end
mbleigh pushed a commit that referenced this issue Sep 2, 2011
@dblock
Copy link
Member

dblock commented Jan 5, 2012

@mbleigh this is done, right?

@dblock
Copy link
Member

dblock commented Feb 14, 2012

The mounting works, but the RHS doesn't. So mounting on "/users" has no effect.

@dblock
Copy link
Member

dblock commented Jan 5, 2013

Fixing this looks complicated. Do we have to alter the paths of the mounted API? Here's a spec for this failure:

      it 'mounts on a path' do
        subject.namespace :cool do
          app = Class.new(Grape::API)
          app.get '/awesome' do
            "sauce"
          end
          mount app => '/mounted'
        end
        get "/mounted/cool/awesome"
        last_response.status.should == 200
        last_response.body.should == "sauce"
      end

@dblock
Copy link
Member

dblock commented Feb 9, 2013

I fixed this, finally, in 70a93a7. It's a bit dirty and in case of nested mounts you must mount outside-in. Maybe @mbleigh can come up with a more elegant fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants