Comments (5)
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.
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.
@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.
@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.
@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)
- Connection refused does not emit exception, future just returns nil instead HOT 4
- FTP client support HOT 3
- JsonResponse error on redirect HOT 2
- Future and nil values HOT 5
- incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) HOT 2
- Stuck processes HOT 5
- Setting SSL options HOT 5
- RestCore::JsonResponse::ParseError on non-success http status code HOT 5
- Listen for "child_added" HOT 4
- support for oj gem HOT 2
- access response content as Tempfile IO object HOT 6
- add dalli extension for hash compatibility HOT 1
- RestBuilder::Promise: ERROR: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) HOT 11
- A payload within a DELETE request is ignored resulting "Invalid request data" from web services. HOT 4
- EventSource vs WebSocket? HOT 5
- "\xAD" from ASCII-8BIT to UTF-8 ERROR when requested GET HOT 7
- Unwanted payload for DELETE request from JsonRequest HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rest-core.