nyny icon indicating copy to clipboard operation
nyny copied to clipboard

ArgumentError at /nested wrong number of arguments (2 for 1) when use namspace route for class app

Open tablecell opened this issue 3 years ago • 0 comments

require 'nyny'
class Ping < NYNY::App
  get '/' do #this will be accessbile at '/ping'
    'pong'
  end
end

class App < NYNY::App
  get '/' do
    'Hello'
  end

  # You can pass a Rack app to the namespace
 namespace '/ping', Ping

  # Or you can pass a block, which will create the app for you
 namespace '/nested' do
 

    get '/' do # this will be accessible at '/nested'
      'Hello from namespace!'
    end
  end
end

visit http://localhost:9292/nested/ is ok visit http://localhost:9292/ping throw ArgumentError it seems that namespace only works fine with block but not for class

tablecell avatar Sep 11 '21 07:09 tablecell