Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cmoore4/phalcon-rest
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoore4 committed Jun 15, 2013
2 parents 85c8607 + 61478ec commit 18c1216
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@
return false;
});*/


/**
* The base route return the list of defined routes for the application.
* This is not strictly REST compliant, but it helps to base API documentation off of.
* By calling this, you can quickly see a list of all routes and their methods.
*/
$app->get('/', function() use ($app){
$routes = $app->getRouter()->getRoutes();
$routeDefinitions = array('GET'=>array(), 'POST'=>array(), 'PUT'=>array(), 'PATCH'=>array(), 'DELETE'=>array(), 'HEAD'=>array(), 'OPTIONS'=>array());
foreach($routes as $route){
$method = $route->getHttpMethods();
$routeDefinitions[$method][] = $route->getPattern();
}
return $routeDefinitions;
});

/**
* Collections let us define groups of routes that will all use the same controller.
* We can also set the handler to be lazy loaded. Collections can share a common prefix.
Expand Down
2 changes: 1 addition & 1 deletion responses/JSONResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function send($records, $error=false){
$records = $this->arrayKeysToSnake($records);
}

$etag = md5($records);
$etag = md5(serialize($records));

if($this->envelope){
// Provide an envelope for JSON responses. '_meta' and 'records' are the objects.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0f8236d6-c6f7-40f2-9b72-440f7de245a9
07576b99-7417-4ad8-a522-49e306a54746

0 comments on commit 18c1216

Please sign in to comment.