diff --git a/examples/07-restful/.htaccess b/examples/07-restful/.htaccess new file mode 100644 index 0000000..d35426b --- /dev/null +++ b/examples/07-restful/.htaccess @@ -0,0 +1,13 @@ + + RewriteEngine On + + RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) + RewriteRule .* - [F] + + RewriteCond %{ENV:REDIRECT_STATUS} 200 + RewriteRule .* - [L] + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)$ index.php?_path_=$1 [QSA,L] + diff --git a/examples/07-restful/index.php b/examples/07-restful/index.php new file mode 100644 index 0000000..b5a0f17 --- /dev/null +++ b/examples/07-restful/index.php @@ -0,0 +1,87 @@ +method == 'HEAD') + { + $res->end(); + } + $res->json([ + 'method' => $req->method, + 'content-type' => $req->get("content-type"), + 'params' => $req->params, + 'body' => $req->body, + ]); +}; + +$app->get('/', function($req, $res) { + $html = << + + + + + + + + + + +EEE; + $res->send($html); +}); +$app->get('contact/:id', $testVerbs); +$app->head('contact/:id', $testVerbs); +$app->post('contact/:id', $testVerbs); +$app->put('contact/:id', $testVerbs); +$app->patch('contact/:id', $testVerbs); +$app->delete('contact/:id', $testVerbs); + +$app->run(); diff --git a/examples/index.php b/examples/index.php index 1f72a5a..4dd90b4 100644 --- a/examples/index.php +++ b/examples/index.php @@ -14,6 +14,7 @@
  • Router
  • POST method
  • Params
  • +
  • RESTful