require './twitter'
module MyWebsite
class SomeResource < Grape::API
resources :user do
post do
# some code here
Twitter::API.endpoint['some_namespace'].call(POST, params)
end
end
end
end--
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
dB. | Moscow - Geneva - Seattle - New York
code.dblock.org - @dblockdotorg - artsy.net - github/dblock
## File: twitter.rb
module Twitter
class API < Grape::API
def self.some_method(a, b)
return a + b
end
end
end
## File: my_website.rb
require './twitter'
module MyWebsite
class SomeResource < Grape::API
resources :user do
post do
Twitter::API.some_method(params[:a], params[:b])
end
end
end
end
There's currently no better way. You should probably refactor the common code out. For an API the "correct" way would be to do a 302 redirect if the result is supposed to be the same, but then there's POST and not all (none?) clients will POST on a redirect.
On Tuesday, January 19, 2016, Michael Fan <fanli...@gmail.com> wrote:
The same question like Call request inside other request. Maybe like:--require './twitter'
module MyWebsite
class SomeResource < Grape::API
resources :user do
post do
# some code here
Twitter::API.endpoint['some_namespace'].call(POST, params)
end
end
end
endIs there a better way do this expect for moving the common used logic code to one independent file or using a RestClient make a HTTP Request outside?
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.