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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes error when launching one specific slice, could be done automatically? #1321

Open
inouire opened this issue Jul 20, 2023 · 0 comments
Open

Comments

@inouire
Copy link

inouire commented Jul 20, 2023

Hello there 馃憢

Here is the situation, I have two slices, each of them has its routes configured in its own routes files. It works when I launch all of them at once with bundle exec hanami server, but not if I specifiy one specific slice with HANAMI_SLICES=deck_api bundle exec hanami server

# frozen_string_literal: true

module Deck
  class Routes < Hanami::Routes
      slice :open_deck, at: "/open-deck"
      slice :deck_api, at: "/api"
  end
end

If I call http://localhost:2301/open-deck, I get Puma caught this error: Slice 'open_deck' not found (Hanami::SliceLoadError)

Here is my patch, which I imagine could be done internally

# frozen_string_literal: true

module Deck
  class Routes < Hanami::Routes
    slices_env = ENV["HANAMI_SLICES"]
  
    if slices_env.blank? || slices_env.include?("open_deck")
      slice :open_deck, at: "/open-deck"
    end

    if slices_env.blank? || slices_env.include?("deck_api")
      slice :deck_api, at: "/api"
    end
  end
end

Should I dig into the "slice" DSL and submit a PR?
Thanks 馃挌

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