diff --git a/app/models/Data/RequestMeta.php b/app/models/Data/RequestMeta.php index f9e7ab9..73678e8 100644 --- a/app/models/Data/RequestMeta.php +++ b/app/models/Data/RequestMeta.php @@ -3,6 +3,7 @@ namespace App\Model\Data; use Phalcon\Mvc\Model; +use Localheinz\Json\Printer\Printer as JsonPrinter; class RequestMeta extends Model { @@ -239,7 +240,13 @@ class RequestMeta extends Model public function getBody() { - return $this->getRequestObject()->getBody(); + $body = $this->getRequestObject()->getBody(); + + if ($this->getType() == 'json') { + $printer = new JsonPrinter(); + return $printer->print($body, ' '); + } + return $body; } /** diff --git a/composer.json b/composer.json index 27c26ec..955c3ff 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,7 @@ "league/oauth2-client": "^2.3", "league/oauth2-github": "^2.0", "league/oauth2-google": "^2.2", - "omines/oauth2-gitlab": "^3.1" + "omines/oauth2-gitlab": "^3.1", + "localheinz/json-printer": "^2.0" } } diff --git a/composer.lock b/composer.lock index c412c31..8031bbd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "7d98cc9a7b6f4f79576273e599f7b1f4", - "content-hash": "0fd142e805b37679388bfea151fd3970", + "hash": "5b02615c35e5c720f8fc96266a7f87a3", + "content-hash": "1e872347d68f7521be008e5a53d4b5e4", "packages": [ { "name": "guzzlehttp/guzzle", @@ -361,6 +361,55 @@ ], "time": "2018-03-19 17:28:55" }, + { + "name": "localheinz/json-printer", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/localheinz/json-printer.git", + "reference": "1a350fd94544df716d1c75ef107d34057f80ac7a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/localheinz/json-printer/zipball/1a350fd94544df716d1c75ef107d34057f80ac7a", + "reference": "1a350fd94544df716d1c75ef107d34057f80ac7a", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "infection/infection": "~0.8.1", + "localheinz/php-cs-fixer-config": "~1.13.1", + "localheinz/test-util": "0.6.1", + "phpbench/phpbench": "~0.14.0", + "phpunit/phpunit": "^6.5.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Localheinz\\Json\\Printer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com" + } + ], + "description": "Provides a JSON printer, allowing for flexible indentation.", + "homepage": "https://github.com/localheinz/json-printer", + "keywords": [ + "formatter", + "json", + "printer" + ], + "time": "2018-04-06 22:10:47" + }, { "name": "omines/oauth2-gitlab", "version": "3.1.0",