Skip to content

Commit

Permalink
FIxes request json payload parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Sep 20, 2023
1 parent a9fee79 commit 2cd447d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

namespace Bow\Event;

use Bow\Session\Session;
use Bow\Container\Action;
use Bow\Support\Collection;
use Bow\Event\Contracts\AppEvent;

class Event
Expand Down
7 changes: 6 additions & 1 deletion src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Bow\Http;

use Bow\Auth\Authentication;
use Bow\Http\Exception\BadRequestException;
use Bow\Session\Session;
use Bow\Support\Collection;
use Bow\Support\Str;
Expand Down Expand Up @@ -52,7 +53,11 @@ private function __construct()
$this->id = "req_" . sha1(uniqid() . time());

if ($this->getHeader('content-type') == 'application/json') {
$data = json_decode(file_get_contents("php://input"), true, 1024, JSON_THROW_ON_ERROR);
try {
$data = json_decode(file_get_contents("php://input"), true, 1024, JSON_THROW_ON_ERROR);
} catch (\Throwable $e) {
throw new BadRequestException("Invalid JSON syntax");
}
$this->input = array_merge((array) $data, $_GET);
} else {
$data = $_POST ?? [];
Expand Down

0 comments on commit 2cd447d

Please sign in to comment.