Router Rack Endpoints Mount any kind of Rack compatible endpoint in Hanami

Router Rack Endpoints

Hanami is compatible with Rack SPEC, and so the endpoints that we use MUST be compliant as well.

A valid endpoint can be a proc, an object, a class, an action, or an application that responds to #call.

get "/proc",       to: ->(env) { [200, {}, ["Hello from Hanami!"]] }
get "/action",     to: "home#index"
get "/middleware", to: Middleware
get "/rack-app",   to:
get "/rails",      to: ActionControllerSubclass.action(:new)

When we use a string, it tries to instantiate a class from it:

get "/rack-app", to: "rack_app" # it will map to

Learn more at Routing overview guide.

Twitter Facebook

Want to learn more about Hanami?

We have written an extensive Getting Started guide for curious people like you.