Skip to content

Conversation

@wprater
Copy link
Contributor

@wprater wprater commented Oct 26, 2012

This is my fix for an message I posted to the group. However, the message appears to be gone. Otherwise, I'd post this pull request to it.

Don't let Rack::Static send a response until after we introspect a response from the API first. If Rack wants us to try to pass along to other middlewares with X-Cascade, then look for static files to serve.

app/acme_app.rb Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this EventLab API? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoot. Of course the tests passed in my side!

I'll fix it up. :)

Please excuse my brevity; message sent from a mobile device.

On Oct 29, 2012, at 8:29, "Daniel Doubrovkine (dB.)" notifications@github.com wrote:

In app/acme_app.rb:

 # api 
  •  response = Acme::API.call(env) 
  •  # error pages 
  •  response = EventLab::API.call(env) 
    What's this EventLab API? :)


Reply to this email directly or view it on GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go! Thanks for catching that.

…sponse from the API first. If Rack wants us to try to pass along to other middlewares with X-Cascade, then look for static files to serve.
@dblock
Copy link
Member

dblock commented Oct 29, 2012

I merged this. But it would be real nice to have a repro and a test for this behavior in the project. In a month we'll all forget by X-Cascade is being checked here.

dblock added a commit that referenced this pull request Oct 29, 2012
Don't let Rack::Static send a response until after we introspect a response from the API first
@dblock dblock merged commit 7561f09 into ruby-grape:master Oct 29, 2012
@wprater
Copy link
Contributor Author

wprater commented Oct 29, 2012

The problem I was having is that Rack::Static was sending 500 Method Not Allowed when sending along anything but a GET request. This way Grape can handle the routes first and pass along if none were matched.

Agreed, a failing test may be good.

@dblock
Copy link
Member

dblock commented Oct 29, 2012

I've been playing with this.

First, I cannot make the nested API to work. I have this:

module Acme class API_ListProducts < Grape::API desc "Get products." get "/" do [ { :name => "Spline 1", :reticulated => true }, { :name => "Spline 2", :reticulated => false } ] end end class API_ShowProduct < Grape::API desc "Get product." get "/:id" do { :name => "Spline #{params[:id]}", :reticulated => true } end end class API_v6 < Grape::API version 'v6', :using => :path, :vendor => 'acme', :format => :json resource :products do mount ::Acme::API_ListProducts mount ::Acme::API_ShowProduct end end end

Doesn't work. I get 405s on /api/v6/products when I mount it inside Api. What are you doing differently?

I can confirm routes looks busted for nested routes. If I can get this to repro I can look at that.

@wprater
Copy link
Contributor Author

wprater commented Oct 30, 2012

Does mounting API modules like this work before my changes? I haven't tried mounting module within a resource before. Only mounting versions within a base API class. But is is indeed failing. However, it fails with a simple

def call(env) # api return response = EventLab::API.call(env) end 

So the issues appears to be within Grape?

@dblock
Copy link
Member

dblock commented Nov 9, 2012

I didn't try like this. If you have a moment, could you try to build a quick api_v6 that works like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants