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

Handling nested Grape mounts? #2156

Open
fatmcgav opened this issue Nov 3, 2017 · 4 comments
Open

Handling nested Grape mounts? #2156

fatmcgav opened this issue Nov 3, 2017 · 4 comments

Comments

@fatmcgav
Copy link

fatmcgav commented Nov 3, 2017

I'm trying to use Grape for providing 'versioned' APIs with Padrino.

I'd like to just mount a single API class in Padrino, e.g.:
Padrino.mount('API', :app_file => Padrino.root('api/base.rb'), :app_class => 'API::Base').to('/api')
Which then mounts the version APIs.

However whenever I try this I get an 'Unitialized Constant' error.
Further details can be found here: https://groups.google.com/forum/?nomobile=true#!topic/padrino/9aA5wFpWp4k and here: fatmcgav/padrino-grape-example@0e3a6c6

@adam12
Copy link
Contributor

adam12 commented Nov 3, 2017

The Unitialized Constant error comes from the v1.rb file not being required.

So the easy fix for that is obviously:

diff --git a/api/base.rb b/api/base.rb
index dd5fd3a..9519b43 100644
--- a/api/base.rb
+++ b/api/base.rb
@@ -1,3 +1,5 @@
+require_relative "v1"
+
 module Aurora
   module API
     class Base < Grape::API

It might break the reloader, but I am not sure if the reloader will even work for Grape applications.

@fatmcgav
Copy link
Author

fatmcgav commented Nov 3, 2017

@adam12 Ah, that was a relatively easy fix...

Though I'm now seeing routes listed twice...

@adam12
Copy link
Contributor

adam12 commented Nov 3, 2017

I'm not sure how much help I'll be there sadly.

@wikimatze
Copy link
Member

Hi @farcaller, I've setup an example app under https://github.com/wikimatze/padrino-nested-grape-mounts which do the nesting in a way I understand modules in grape as explained under https://github.com/ruby-grape/grape#modules - just follow the README in https://github.com/wikimatze/padrino-nested-grape-mounts/blob/master/README.md to see what I did.

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

No branches or pull requests

3 participants