Skip to content

Instantly share code, notes, and snippets.

@zukasmichael
Created November 14, 2017 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zukasmichael/02354827897bb9facb6dc8718952755d to your computer and use it in GitHub Desktop.
Save zukasmichael/02354827897bb9facb6dc8718952755d to your computer and use it in GitHub Desktop.
// json request parser
$app->before(function ($request) {
if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) {
$data = json_decode($request->getContent(), true);
$request->request->replace(is_array($data) ? $data : []);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment