Hello wonderful community!
Today we're happy to announce
v1.2.0.beta1 release 🙌 , with the stable release (
v1.2.0) scheduled for April 2018.
So what this cold winter ❄ has brought to you from the Hanami world?
We didn't ship that feature because Rack and web servers didn't support Push Promise, so I had to write a toy HTTP/2 web server for Rack.
Given the adoption of HTTP/2 is slow, the IETF "backported" this feature to HTTP/1. This feature today is known as Early Hints (103) status code.
A web application can tell the browser which resources to fetch in advance in order to boost the page loading.
Given that now Rack and Puma support Early Hints (103) and we had already in place the code to support this kind of feature, we're excited to release it today!
In order to use it, you need to use Puma with Early Hints feature enabled.
# config/puma.rb # ... early_hints true
Inside the project configuration you can simply enable like this:
# config/environment.rb Hanami.configure do # ... early_hints true end
If you're looking for a full working example, please check this demo app.
Today we introduce a new gem in the Hanami family:
hanami-ujs is based on the really good
As first thing, you must add
hanami-ujs to your
Gemfile and run
Then you have to add two lines to the application layout (eg.
<%= csrf_meta_tags %>inside
</body>is a good spot.
Now we can use the new option for
<%= form_for :search, "/search", remote: true do # ... submit "Search" end %>
When you will push "Search" the form will be sent via AJAX.
New Hanami projects will be generated with a new gem in
It's is an improved development error page with a built-in REPL to debug Ruby code from the browser.
This feature is based on
better_errors gem, which historically didn't play well with Hanami.
So we packaged into a Hanami plugin to make the developer experience frictionless.
v1.1.0 you can enhance the CLI experience of
hanami by registering your own commands (eg.
hanami generate webpack ).
Starting from today you can register callbacks for existing commands to hook into their execution.
Imagine to build a gem
hanami-database-analyzer to print the number of tables from the development database:
Hanami::CLI.after("db migrate") do puts "the database has 23 tables" end
When a user will execute
hanami db migrate, that callback will be called:
% bundle exec hanami db migrate # migrations output ... the database has 23 tables
With this release we're introducing Rack middleware stack at the project level.
# config/environment.rb Hanami.configure do middleware.use MyRackMiddleware end
This is equivalent to use a middleware from
config.ru, the main difference is that the new Rack middleware can be programmatically manipulated by third-party gems (aka plugins). (See the next feature).
Third-party gems (aka plugins) can now manipulate the Hanami configuration of a project.
For instance from the
hanami-webconsole gem, we mount a Rack middleware into the host project:
Hanami.plugin do middleware.use BetterErrors::Middleware end
gem install hanami --pre hanami new bookshelf
We'll release new beta versions, with enhancements, and bug fixes. The stable release is expected on April 2018, in the meantime, please try this beta and report issues.
Happy coding! 🌸