Skip to content

Commit

Permalink
Change get body to works with Octane
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielpeixoto committed Mar 29, 2023
1 parent 266fe21 commit 4cab09d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/SNSController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function callback(Request $request)
// for SNSMessage we have to pass the json data in $request->message
$message = new SNSMessage(json_decode($request->message, true));
} else {
$message = SNSMessage::fromRawPostData();
$message = $this->fromJsonString($request);
$validator = app(SNSMessageValidator::class);
$validator->validate($message);
}
Expand All @@ -44,6 +44,23 @@ public function callback(Request $request)
}
}

/**
* @param \Illuminate\Http\Request $request
* @return \Aws\Sns\Message
*/
private function fromJsonString(Request $request)
{
// get body from request
$body = $request->getContent();

// Make sure the SNS-provided header exists.
if (!isset($_SERVER['HTTP_X_AMZ_SNS_MESSAGE_TYPE'])) {
throw new \RuntimeException('SNS message type header not provided.');
}

return SNSMessage::fromJsonString($body);
}

protected function confirm_subscription($message)
{
$client = new Guzzle();
Expand Down

0 comments on commit 4cab09d

Please sign in to comment.