Code Monkey home page Code Monkey logo

Comments (5)

godfat avatar godfat commented on September 15, 2024

Sorry, I am not exactly sure what's the issue you're seeing? Could you describe it? I don't see any errors in your post, and I just tried it and it worked fine.

from rest-core.

VivekTamtaFluke avatar VivekTamtaFluke commented on September 15, 2024

Thanks for looking into it.
Earlier I meant I am getting response as NIL for the mentioned

require 'rest-core'
 YourClient = RC::Builder.client do
 use RC::DefaultSite , 'https://api.github.com/users/'
 use RC::JsonResponse, true
 use RC::CommonLogger, method(:puts)
 use RC::Cache       , nil, 3600 # :expires_in if cache store supports
end

Well this is what I am doing

m-bang-vtamta:sw-web vivek$ irb
2.4.0 :001 > require 'rest-core'
 => true 
2.4.0 :002 > YourClient = RC::Builder.client do
2.4.0 :003 >       use RC::DefaultSite , 'https://api.github.com/users/'
2.4.0 :004?>     use RC::JsonResponse, true
2.4.0 :005?>     use RC::CommonLogger, method(:puts)
2.4.0 :006?>     use RC::Cache       , nil, 3600 # :expires_in if cache store supports
2.4.0 :007?>   end
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:158: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:166: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/middleware.rb:52: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:49: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:73: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:97: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:121: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:145: warning: circular argument reference - app
 => YourClient 
2.4.0 :008 > YourClient.new
 => #<struct YourClient site=nil, json_response=nil, log_method=nil, cache=nil, expires_in=nil> 
2.4.0 :009 > 

Please let me know if anything you want to know more. And thanks again for you time.

from rest-core.

godfat avatar godfat commented on September 15, 2024

@VivekTamtaFluke Sorry that I edited your post to fix the format, otherwise it's very hard to read it.

First that you're using an very old version, so please upgrade to 4.0.0.

And I am still not sure why you're saying that you got nil for the response. In the code you posted, it's not making any requests, it's only making a client, which could be used to make a request.

In your case, you might want to:

client = YourClient.new
client.get('VivekTamtaFluke')

So then you're making a request to https://api.github.com/users/VivekTamtaFluke, which should give you the response.

Please try it and let me know if you have other questions.

from rest-core.

VivekTamtaFluke avatar VivekTamtaFluke commented on September 15, 2024

@godfat Thanks for editing the post.

Yes I am using old version. Since in the later versions the middleware and wrapper layer is combined and we have a legacy code which I am currently not authorised to change.
And yes we do have to update at sometime.

Meanwhile what I am trying here is to get the same output which I get when I run this with Ruby 2.0.0. and rest-core 2.1.2

require 'rest-core'
 YourClient = RC::Builder.client do
 use RC::DefaultSite , 'https://api.github.com/users/VivekTamtaFluke'
 use RC::JsonResponse, true
 use RC::CommonLogger, method(:puts)
 use RC::Cache       , nil, 3600 # :expires_in if cache store supports
end

and getting this

m-bang-vtamta:sw-web vivek$ irb
2.0.0-p247 :001 > require 'rest-core'
 => true 
2.0.0-p247 :002 >  YourClient = RC::Builder.client do
2.0.0-p247 :003 >      use RC::DefaultSite , 'https://api.github.com/users/VivekTamtaFluke'
2.0.0-p247 :004?>    use RC::JsonResponse, true
2.0.0-p247 :005?>    use RC::CommonLogger, method(:puts)
2.0.0-p247 :006?>    use RC::Cache       , nil, 3600 # :expires_in if cache store supports
2.0.0-p247 :007?>   end
 => YourClient 
2.0.0-p247 :008 > YourClient.new
 => #<struct YourClient site="https://api..., json_response=true, log_method=#<Method: Re..., cache=nil, expires_in=3600> 
2.0.0-p247 :009 > 

You can see here I am getting something in response, which is not the case with Ruby 2.4.0 and rest-core 3.0.0

Can you help me to understand what wrong I am doing here.

from rest-core.

godfat avatar godfat commented on September 15, 2024

@VivekTamtaFluke ok, we could forget about upgrading for now, but if you're going to use Ruby 2.4.0, I am not very sure if that would work, because the warnings you're seeing.

I still don't understand what's the response you're talking about? You didn't make any requests in the code you posted, so of course you're not getting any response. This should be the same across any of the versions.

Like I said before, you would want to make a request like this:

client.get('VivekTamtaFluke')

from rest-core.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.