Allowing a url with multiple formats

That’s great :slight_smile:

In terms of mounting a Hanami app inside a Rails app, I haven’t done it but Hanami.app is a Rack-compatible app.

So, if you want to mount it based on a special distinct path, you could edit your config.ru file with something like:

# Require the Hanami app
# Adjust the path as needed
require_relative '../my_hanami_app/config/environment' # or wherever Hanami.app is defined

# Mount the apps
map '/new' do
  run Hanami.app
end

(And likely switch to using rackup instead of rails server, so it loads it properly).

Though you’d have to be careful about constants having naming collisions. Hanami puts everything inside namespaces, so hopefully it wouldn’t be too bad.

Additionally, @stephan recently mounted a single Hanami slice inside a Rails app recently and worked through some of the rough edges: Proof of Concept: A Hanami slice in a Rails app It’s worth going through his posts to see how he resolved some of the issues he found. The main Hanami.app which holds Slices is also a slice itself (though a special one) so much of it should be applicable for mounting a whole app.

1 Like