Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

BodyParams middleware stolen w/permission from mwop.net #3

Merged
merged 3 commits into from
Dec 22, 2015
Merged

BodyParams middleware stolen w/permission from mwop.net #3

merged 3 commits into from
Dec 22, 2015

Conversation

michaelmoussa
Copy link
Contributor

@weierophinney this should be a good start for what we discussed last week. I just copied what you had, tweaked the namespace/class name, added comments, and added tests.

I'm not entirely sure what you meant by "attaching other strategies" in your follow-up tweet, though. If you can give me an example, we can work it in, but it certainly fits the need in my project as-is.

@weierophinney weierophinney added this to the 1.3.0 milestone Dec 22, 2015
@weierophinney weierophinney self-assigned this Dec 22, 2015
weierophinney added a commit to weierophinney/zend-expressive-helpers that referenced this pull request Dec 22, 2015
BodyParams middleware stolen w/permission from mwop.net
weierophinney added a commit to weierophinney/zend-expressive-helpers that referenced this pull request Dec 22, 2015
This patch builds on the one in zendframework#3, moving the act of parsing a Content-Type as
well as parsing the request body to *strategies*, which implement
`Zend\Expressive\BodyParams\StrategyInterface`. These define two methods:

- `match($contentType)`, which should accept a Content-Type header value, and
  return a boolean value indicating whether or not the strategy matches.
- `parse(ServerRequestInterface $request)`, which should accept the request
  instance, parse its raw body, and return a new request instance with the
  results of parsing injected as the parsed body.

The form and json matching/parsing were rewritten as strategies, and added as
default strategies to the middleware. Custom strategies can be written and then
attached using `addStrategy()`.
weierophinney added a commit that referenced this pull request Dec 22, 2015
weierophinney added a commit that referenced this pull request Dec 22, 2015
@weierophinney weierophinney merged commit eaaf296 into zendframework:master Dec 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants