Added
- Add
Hanami::Router#routes, returning a frozen array of the router's routes, in the order they were defined. The router now records its routes at all times, so they are available at runtime (for example, to list them on a "not found" error page). (@afomera and @timriley in #306) - Make
Hanami::Router::Formatter::HumanFriendlyandHanami::Router::Formatter::CSVpublic API. A formatter is any object that responds to#call(routes, **options)and returns a String. Use one to render routes:Hanami::Router::Formatter::HumanFriendly.new.call(router.routes). (@timriley in #306) - Support for HTTP QUERY method. (@katafrakt in #307)
Changed
- Generate most paths without Mustermann, making
#pathand#urlaround 10 times faster, and routers with many named routes quicker to build. (@parndt in #311) - Raise
FrozenErrorwhen adding a route to, or mounting an app on, a frozen router. Previously, the route was added to the routing tables and served requests, even though the router was frozen. (@timriley in #306)
Removed
- BREAKING: Remove
Hanami::Router::Inspector, theinspector:argument toHanami::Router.new, andHanami::Router#inspector. Use#routeswith a formatter instead:Hanami::Router::Formatter::HumanFriendly.new.call(router.routes). If you use hanami and hanami-cli, upgrade those to v3.1, which use the formatters directly. (@timriley in #306)
Fixed
- Allow route names to give only a prefix, with an
as:of[prefix, nil]. Previously, this gave a name with a trailing underscore. For example,scope "admin" do get "/", to: dashboard, as: [:dashboard, nil] endnow givesdashboard_admin, rather thandashboard_admin_. (@timriley in #314) - Record the full prefixed path for apps mounted within a scope or under a router prefix. Previously,
mount app, at: "/api"withinscope "v1"was listed with the path/apiinstead of/v1/api. (@timriley in #306) Trie#findkeeps every path it looks up. (@aaronmallen in #312)