protected function requestHandler($request, $dbAdapter)
 {
     if ($request->method == 'GET') {
         //check to see if path contains more than one level, if only one level exists trigger regular get if more than one level is present determine if path is valid and trigger correct get
         $path_count = count($request->path_info);
         if ($path_count == 1) {
             if (count($request->parameters) == 0) {
                 //check if parameters exist, if no parameters return all of the records LIMIT 1000
                 $this->getAll($request, $dbAdapter);
             } else {
                 //if fields is set call function to return all records of user selected fields
                 $this->parameterHandler($request, $dbAdapter);
             }
         } elseif ($path_count == 2 && preg_match('/^[0-9]{1,6}+$/', $request->path_info[1])) {
             //path should contain at most 3 levels, level two should only contain alpha characters and be two characters long.
             $this->getById($request, $dbAdapter);
         } elseif ($path_count == 3) {
             try {
                 $this->getByPath($request, $dbAdapter);
             } catch (Exception $e) {
                 graceful404();
             }
         } else {
             graceful404();
         }
     } else {
         graceful404('Method type is not supported');
     }
 }
function handleRequest($dbAdapter)
{
    $request = new Request();
    $controller_name = ucfirst($request->path_info[0] . 'Controller');
    if (apiAutoload($controller_name)) {
        $controller = new $controller_name($request, $dbAdapter);
    } else {
        graceful404();
    }
    return true;
}