Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakage with trailing slash #1

Open
HoneyryderChuck opened this issue Dec 22, 2016 · 0 comments
Open

Breakage with trailing slash #1

HoneyryderChuck opened this issue Dec 22, 2016 · 0 comments

Comments

@HoneyryderChuck
Copy link

I get a backtrace crash with a very simple example: I set a rest resource endpoint, and when I GET the endpoint without the trailing slash, it works. When I don't, it throws an error and gets unhandled. Here's part of the backtrace that might be relevant:

#<ArgumentError: wrong number of arguments (given 1, expected 0)>                                                     
/home/.bundle/ruby/2.3.0/gems/roda-rest_api-2.0.1/lib/roda/plugins/rest_api.rb:233:in `block in index'
/home/.bundle/ruby/2.3.0/gems/roda-2.20.0/lib/roda.rb:807:in `if_match'
/home/.bundle/ruby/2.3.0/gems/roda-2.20.0/lib/roda.rb:743:in `_verb'
/home/.bundle/ruby/2.3.0/gems/roda-2.20.0/lib/roda.rb:370:in `get'
/home/.bundle/ruby/2.3.0/gems/roda-rest_api-2.0.1/lib/roda/plugins/rest_api.rb:234:in `index'
/home/.bundle/ruby/2.3.0/gems/roda-rest_api-2.0.1/lib/roda/plugins/rest_api.rb:89:in `block in routes!'

Here is a small route dec to reproduce the issue:

route do |r|
  r.on "foo" do
    "bar"
  end
  r.api path: '' do
    r.version 1 do
      r.resource :foos do |foos|
        foos.list { %w(bar) * 8  }
      end
    end
  end
end

Now use curl and fetch the following URLs:

  • http://%{host}:{port}/foo
  • http://%{host}:{port}/foo/
  • http://%{host}:{port}/v1/foos
  • http://%{host}:{port}/v1/foos/

With this example I demonstrate that the problem is not roda (I'm using 2.21), which correctly handles the trailing slash. You can also see that this gem uses the #get method to set the show/index, and roda doesn't handle trailing slashes with this. But even when that happens, roda doesn't crash (just 404's).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant