Example #1
0
 /**
  * Walks a request though the HTTP Flow Chart
  * @param  string   $resource Target Resource
  * @param  Request  $request
  * @param  Response $response
  * @return Response
  */
 public static function handleRequest($resource, Request $request, Response $response)
 {
     try {
         // Temporary
         $response->add_metadata('start-time', microtime(true));
         $context = $resource::init($request);
         $state = new DecisionCoreState($resource, $request, $response, $context);
         // I think the loop will be more effecient than recursion in PHP
         $decision = 'v3b13';
         while ($decision != 'stop') {
             $decision = static::decision($decision, $state);
         }
         return $response;
     } catch (Exception $e) {
         static::errorResponse($e->getMessage() . '\\n' . $e->getTraceAsString(), $state);
     }
 }