hanami / controller

Complete, fast and testable actions for Rack and Hanami

Home Page:http://hanamirb.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rename `Hanami::Action.content_type` into `.accept`

jodosha opened this issue · comments

With #247 (v1.2.0) we introduced Hanami::Action.content_type which is a DSL that restrict the access based on request's Content-Type of the payload and halt with 415 Unsupported Media Type in case of mismatch.

On the other hand we already had .accept (v0.1.0), which was built to do the exact same thing, but it targets Accept header instead.

To recap: the actual Hanami::Action.content_type has the right implementation, but it should be named .accept instead.

class MyAction < Hanami::Action
  accept :json

  def call(*)
    # ...
  end
end

This will let to pass only the requests that have a matching Content-Type header.


This change MUST go to unstable branch.


Ref #247
Ref fd9e080

Seems this can be closed, as related PR #265 has been merged.

Thanks @tak1n, closing this now :)