Commit 3d6daa4c authored by Igor Wiedler's avatar Igor Wiedler Committed by Fabien Potencier

allow all HTTP verbs if not specified, adjust documentation

parent 2ffd9d14
...@@ -9,17 +9,17 @@ Silex is a simple web framework to develop simple websites: ...@@ -9,17 +9,17 @@ Silex is a simple web framework to develop simple websites:
use Silex\Framework; use Silex\Framework;
$framework = new Framework(array( $framework = new Framework(array(
'GET /hello/:name' => function($name) '/hello/:name' => function($name)
{ {
return new Response('Hello '.$name); return new Response('Hello '.$name);
}, },
'POST /goodbye/:name' => function($name) 'GET|PUT|POST /goodbye/:name' => function($name)
{ {
return new Response('Goodbye '.$name); return new Response('Goodbye '.$name);
}, },
)); ));
$framework->handle()->send(); $framework->run();
Silex is based on [Symfony2][1]. Silex is based on [Symfony2][1].
......
No preview for this file type
...@@ -35,11 +35,12 @@ class Framework extends BaseHttpKernel ...@@ -35,11 +35,12 @@ class Framework extends BaseHttpKernel
foreach ($map as $pattern => $to) { foreach ($map as $pattern => $to) {
if (false !== strpos($pattern, ' ')) { if (false !== strpos($pattern, ' ')) {
list($method, $pattern) = explode(' ', $pattern, 2); list($method, $pattern) = explode(' ', $pattern, 2);
$method = explode('|', $method);
} else { } else {
$method = 'GET'; $method = array();
} }
$route = new Route($pattern, array('_controller' => $to), array('_method' => explode('|', $method))); $route = new Route($pattern, array('_controller' => $to), array('_method' => $method));
$this->routes->addRoute(str_replace(array('/', ':'), '_', $pattern), $route); $this->routes->addRoute(str_replace(array('/', ':'), '_', $pattern), $route);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment