Name: payload
Owner: Middlewares
Description: PSR-15 middleware to parse the body of the request with support for json, csv and url-encode
Created: 2016-10-04 09:48:42.0
Updated: 2018-03-21 23:52:03.0
Pushed: 2018-01-25 22:09:30.0
Homepage: null
Size: 36
Language: PHP
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Parses the body of the request if it's not parsed and the method is POST, PUT or DELETE. It contains the following components to support different formats:
This package is installable and autoloadable via Composer as middlewares/payload.
oser require middlewares/payload
Parses the json payload of the request. Contains the following options to configure the json_decode function:
associative(bool $associative)
Enabled by default, convert the objects into associative arrays.
depth(int $depth)
To configure the recursion depth.
options(int $options)
To pass the bitmask of json_decode options.
methods(array $methods)
To configure the allowed methods. By default only the requests with the method POST, PUT, PATCH, DELETE, COPY, LOCK, UNLOCK
are handled.
contentType(array $contentType)
To configure all Content-Type headers allowed in the request. By default is application/json
override($override = true)
To override the previous parsed body if exists (false
by default)
patcher = new Dispatcher([
(new Middlewares\JsonPayload())
->associative(false)
->depth(64)
ponse = $dispatcher->dispatch(new ServerRequest());
Parses the url-encoded payload of the request. There's no options.
methods(array $methods)
To configure the allowed methods. By default only the requests with the method POST, PUT, PATCH, DELETE, COPY, LOCK, UNLOCK
are handled.
contentType(array $contentType)
To configure all Content-Type headers used in the request. By default is application/x-www-form-urlencoded
override($override = true)
To override the previous parsed body if exists (false
by default)
patcher = new Dispatcher([
new Middlewares\UrlEncodePayload()
ponse = $dispatcher->dispatch(new ServerRequest());
Parses the csv payload of the request. Contains the following options to configure the SplTempFileObject object:
delimiter($delimiter)
To configure the Csv delimiter control character (one character only). If the submitted character is invalid an InvalidArgumentException
exception is thrown.
enclosure($enclosure)
To configure the Csv enclosure control character (one character only). If the submitted character is invalid an InvalidArgumentException
exception is thrown.
escape($escape)
To configure the Csv escape control character (one character only). If the submitted character is invalid an InvalidArgumentException
exception is thrown.
methods(array $methods)
To configure the allowed methods. By default only the requests with the method POST, PUT, PATCH, DELETE, COPY, LOCK, UNLOCK
are handled.
contentType(array $contentType)
To configure all Content-Type headers used in the request. By default is text/csv
override($override = true)
To override the previous parsed body if exists (false
by default)
patcher = new Dispatcher([
(new Middlewares\CsvPayload())
->delimiter(";")
->enclosure("'")
->escape("\\")
ponse = $dispatcher->dispatch(new ServerRequest());
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.