Skip to content

Commit

Permalink
Hanami v2.0.3 (#568)
Browse files Browse the repository at this point in the history
* Hanami v2.0.3

* CHANGELOG entry
  • Loading branch information
jodosha authored Feb 1, 2023
1 parent 5cd3341 commit c602b4f
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def current_ruby_version
end

def hanami_version
'2.0.2'
"2.0.3"
end

def hanami_release_date
Date.parse("2022-12-25").strftime("%B %-d, %Y")
Date.parse("2023-02-01").strftime("%B %-d, %Y")
end
end

Expand Down
129 changes: 129 additions & 0 deletions source/blog/2023-02-01-hanami-203.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
title: "Hanami 2.0.3"
date: 2023-02-01 07:59:05 UTC
tags: announcements
author: Luca Guidi
image: true
excerpt: >
Hanami v2.0.3: params pattern matching, HTTP statuses as symbols, small enhancements and bug fixes
---

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:

```ruby
# 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](https://guides.hanamirb.org/v2.0/actions/status-codes/).

```ruby
# 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
```

```ruby
# 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:

```shell
$ bundle update hanami-utils hanami-controller hanami-cli hanami
```

How to try Hanami for the first time:

```shell
$ 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!

- [Luca Guidi](https://github.com/jodosha)
- [Pat Allan](https://github.com/pat)
- [Adam Lassek](https://github.com/alassek)
- [R Gibim](https://github.com/Drowze)
- [hi-tech-jazz](https://github.com/hi-tech-jazz)
- [dsisnero](https://github.com/dsisnero)

🌸
Binary file added source/blog/2023-02-01-hanami-203/cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c602b4f

Please sign in to comment.