-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
37 lines (29 loc) · 919 Bytes
/
index.php
File metadata and controls
37 lines (29 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
// Require composer autoloader
require __DIR__ . '/vendor/autoload.php';
require 'controller/controller.php';
// Create Router instance
$router = new \Bramus\Router\Router();
$router -> before('GET', '/.*', function() {
header('X-Powered-By: router');
});
$router->get('/', function() {
echo "Welcome to beautyUniversity JSON api";
});
$router->get('/v1/school/(\w+)/analytic/(\w+)', function($name, $bool) {
header('Content-Type: application/json; charset=utf-8');
ob_start("ob_gzhandler");
$req = htmlentities($name);
$check = htmlentities($bool);
$controller = new myController($req);
if($check === "true")
echo $controller -> indexAction("colleges_" . $req);
if($check === "false")
echo $controller -> indexAction("school_" . $req);
});
$router->set404(function() {
header('HTTP/1.1 404 Not Found');
echo "invalid request url";
});
$router -> run();
?>