controller icon indicating copy to clipboard operation
controller copied to clipboard

What should go here to configure Hanami router?

Open radar opened this issue 4 years ago • 0 comments

If we're using hanami-router 2.0.0.alpha3 + hanami-controller 2.0.0.alpha1 and attempt to use the syntax as suggested in hanami-controller's README, we see this error:

ArgumentError:
  unknown keyword: :configuration

We can define routes without this keyword:

module Twist
  module Web
    Router = Hanami::Router.new do
      if ENV['APP_ENV'] == "development"
        require 'sidekiq/web'
        mount Sidekiq::Web, at: '/sidekiq'
      end

      post '/graphql', to: Controllers::Graphql::Run.new
      options '/graphql', to: Controllers::Graphql::Run.new

      post '/books/:permalink/receive', to: Controllers::Books::Receive.new

      get '/oauth/authorize', to: Controllers::Oauth::Authorize.new
      get '/oauth/callback', to: Controllers::Oauth::Callback.new
    end
  end
end

However, each new call here apparently needs a configuration keyword:

ArgumentError:
  missing keyword: :configuration
# ./lib/twist_web/router.rb:9:in `block in <module:Web>'

Looks like if I use the unstable branches of both hanami-controller + hanami-router, I can get away without providing a configuration key (using the above router configuration).

So perhaps this PR should be to remove the configuration and possibly also the namespace options from the Hanami::Router call?

radar avatar Jan 13 '21 22:01 radar