Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Hanami::Middleware::BodyParser::Parser #189

Merged
merged 2 commits into from
Dec 5, 2020

Conversation

jodosha
Copy link
Member

@jodosha jodosha commented Jul 29, 2019

What?

Introduce Hanami::Middleware::BodyParser::Parser as superclass for body parsers

Why?

By reviewing this documentation fix, I've recognized that in unstable branch the superclass for body parsers is gone.

Since 1.3, we put in place a mechanism to check if a given body parser respond to the required methods (see #182). In a language with missing interfaces, this is the best that we can do.


However, we cannot easily document the behavior of these methods.

For instance, we currently assert that a parser responds to #mime_types, but we can't document that we expect an array of strings as returning value.

Same thing goes for #parse, which is even more complex due to the expected exception to be raised.

How?

The superclass is used by our only body parser for JSON.

It doesn't change the current possibility of having a body parser that implicitly inherits from Object. This PR only indicates the preferred way.

@jodosha jodosha added this to the v2.0.0 milestone Jul 29, 2019
@jodosha jodosha self-assigned this Jul 29, 2019
@jodosha jodosha merged commit 5a088e7 into unstable Dec 5, 2020
@jodosha jodosha deleted the enhancement/body-parser-superclass branch January 16, 2021 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant