-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute-api.php
More file actions
18 lines (14 loc) · 899 Bytes
/
route-api.php
File metadata and controls
18 lines (14 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
require_once('lib/Router/Route.php');
require_once('api/controller/CommentController.php');
define("BASE_URL", 'http://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].dirname($_SERVER["PHP_SELF"]).'/');
$router = new Router();
// routes
$router->addRoute("/comment/:ID", "GET", "CommentController", "getCommentsByProductId");
$router->addRoute("/comment/:ID", "DELETE", "CommentController", "deleteComment");
$router->addRoute("/comment", "POST", "CommentController", "addComment");
$router->addRoute("/comment", "GET", "CommentController", "getAll");
$router->addRoute("/comment/:ID/:SORT/:ORDER", "GET", "CommentController", "getFilteredComments");
$router->addRoute("/comment/:ID/:SORT", "GET", "CommentController", "getCommentsByPunctuation");
//run
$router->route($_GET['resource'], $_SERVER['REQUEST_METHOD']);