Hello again, friends! New month, new Hanami release: v2.0.3!
It ships with small enhancements and minor bug fixes.
Params Pattern Matching
Pattern Matching on request params is helpful to expand values into local variables:
# frozen_string_literal: true
module MyApp
module Actions
module Graphql
class Show < MyApp::Action
# ...
def handle(req, res)
# ...
req.params => {query:, variables:}
res.body = schema.execute(query, variables:).to_json
end
end
end
end
end
HTTP Statuses as Symbols
From now on it's possible to reference the HTTP statuses, not only via an Integer
, but also with a Symbol
.
Check our guides, for the entire list of allowed HTTP statuses.
# frozen_string_literal: true
module MyApp
module Actions
module Account
class Show < MyApp::Action
def handle(req, res)
halt :unauthorized unless logged_in?
# ...
end
end
end
end
end
# frozen_string_literal: true
module MyApp
module Actions
module Account
class Update < MyApp::Action
def handle(req, res)
unless req.params.valid?
res.status = :unprocessable_entity
# ...
end
end
end
end
end
end
Enhancements and Bug Fixes
- Ensure to setup a logger in a non-default Hanami env
- Use production logger settings for non-default Hanami env
- Ensure action accepting the request with a custom MIME Type
- Fix error message for missing format (MIME Type)
- Allow slices to have a default for registrations directory
- Halting with an unknown HTTP code will raise a
Hanami::Action::UnknownHttpStatusError
- Ensure to run automatically bundle gems when using
hanami new
on Windows - Ensure to generate the correct action identifier in routes when using
hanami generate action
with deeply nested action name Hanami::Utils::Blank.blank?
to check if the current object is non-nil
Released Gems
hanami
2.0.3
hanami-cli
2.0.3
hanami-controller
2.0.2
hanami-utils
2.0.3
How To Upgrade
How to upgrade from a Hanami app:
$ bundle update hanami-utils hanami-controller hanami-cli hanami
How to try Hanami for the first time:
$ gem install hanami
$ hanami new bookshelf
$ cd bookshelf
$ bundle exec hanami server # visit http://localhost:2300
Thank You
Thank you also to these wonderful people for contributing to Hanami 2.0.3!
🌸