Note that there are some explanatory texts on larger screens.

plurals
  1. POCan open-uri be used across rack applications?
    primarykey
    data
    text
    <p>Currently I have a Sinatra web app &amp; a Grape API, the idea being to implement the Sinatra app in such a way that the web app is just another API consumer. </p> <p>In my config.ru I have this:</p> <pre><code>run Rack::Cascade.new [API, Application] </code></pre> <p><code>API</code> is the Grape app &amp; <code>Application</code> is the Sinatra app. I am using open-uri to try to grab the JSON from the Grape api in a Sinatra route. I am using thin. <em>I am omitting the /uri after the port number for ease of reading, the Grape &amp; Sinatra apps work independently, I will explain further in a moment</em></p> <p><code>open("http://localhost")</code> returns: </p> <pre><code>#&lt;StringIO:0x007fbeab1b2e68 @base_uri=#&lt;URI::HTTP:0x007fbeab1d47e8 URL:http://localhost&gt;, @meta= {"content-type"=&gt;"text/html; charset=utf8", "x-pow-template"=&gt;"welcome", "date"=&gt;"Fri, 06 Sep 2013 07:29:15 GMT", "connection"=&gt;"keep-alive", "transfer-encoding"=&gt;"chunked"}, @status=["200", "OK"]&gt; </code></pre> <p>However, if I <code>open("http://localhost:9292")</code> the application hangs. I feel like maybe something is blocking I/O, like perhaps its waiting for itself to connect to itself but I am not sure enough of whats going on <em>under the hood</em> to really be sure.</p> <p>If I point pow at it, spin it up at <code>project.dev</code> &amp; then spin it up with <code>rackup</code> so I have two instances I can use <code>open("http://project.dev/what/ever/url/i_need")</code> &amp; it works like a charm. So the problem seems to be somewhere in pointing open-uri at itself... I think...</p> <p>Is this because of the <code>Rack::Cascade</code>? is this a problem with <code>thin</code>? or maybe the with <code>open-uri</code>? Is this just completely the wrong way to approach this problem?</p> <p>I am open to just about any solution however I would prefer to keep it as simple as possible, with minimal external requires as I intent to use this pattern frequently.</p> <p>Let me know if any additional information is required &amp; I will do my best to provide it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload