Skip to content

Commit

Permalink
Added Demo for new Route options
Browse files Browse the repository at this point in the history
  • Loading branch information
gmanricks committed Apr 28, 2013
1 parent d9aa70f commit 662691d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
11 changes: 11 additions & 0 deletions Controller/Main.php
Expand Up @@ -14,6 +14,17 @@ public function test($title)
$this->render("test", array("title" => $title, "name" => "Test"));
}

public function test2()
{
$this->render("test", array("title" => "GET", "name" => "Test 2"));
}

public function test3()
{
$this->render("test", array("title" => "POST", "name" => "Test 3"));
}


public function notFound()
{
$this->render("error", array(), 404);
Expand Down
9 changes: 8 additions & 1 deletion public/index.php
Expand Up @@ -6,7 +6,14 @@

$routes = array(
'/' => '',
'/test/:title' => "Main:test@get"
'/test/:title' => "Main:test@get",

array('/arr', "Main:index@get"),

'/demo' => array(
"get" => "Main:test2",
"post" => "Main:test3"
)
);

$router->addRoutes($routes);
Expand Down
4 changes: 2 additions & 2 deletions vendor/NetTuts/Router.php
Expand Up @@ -38,10 +38,10 @@ protected function addRoute($route, $pathStr) {
$method = "any";

if (strpos($pathStr, "@") !== false) {
list($pathStr, $method) = explode("@", $path);
list($pathStr, $method) = explode("@", $pathStr);
}

$func = $this->processCallback($path);
$func = $this->processCallback($pathStr);

$r = new \Slim\Route($route, $func);
$r->setHttpMethods(strtoupper($method));
Expand Down

0 comments on commit 662691d

Please sign in to comment.