Пример #1
0
 protected function registerBeforeListeners(Application $app)
 {
     // Quick'n'dirty content negotiation.
     $app->before(function (Request $request, Application $app) {
         $request->setFormat('hal_json', 'application/hal+json');
         foreach ($request->getAcceptableContentTypes() as $mime_type) {
             if ($format = $request->getFormat($mime_type)) {
                 $request->setRequestFormat($format);
                 return;
             }
         }
         // Application-specific default.
         $request->setRequestFormat('json');
     });
 }