-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
54 lines (42 loc) · 1008 Bytes
/
index.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require 'vendor/autoload.php';
$router = new AltoRouter();
/*
* Map our routes
*/
$router->map( 'GET', '/', function()
{
require __DIR__ . '/home.php';
}, 'home');
$router->map( 'GET', '/business/[a:id]', function($id)
{
require __DIR__ . '/business.php';
}, 'business-details' );
$router->map( 'GET', '/search/', function()
{
require __DIR__ . '/search.php';
}, 'search' );
$router->map( 'GET', '/api/business/[a:id]', function($id)
{
require __DIR__ . '/api/business.php';
}, 'api-business-details' );
$router->map( 'GET', '/api/search/[a:query]', function($query)
{
require __DIR__ . '/api/search.php';
}, 'api-search' );
$router->map( 'GET', '/api/recent', function()
{
require __DIR__ . '/api/recent.php';
}, 'api-recent');
$match = $router->match();
if ( is_array($match) && is_callable( $match['target'] ) )
{
call_user_func_array( $match['target'], $match['params'] );
}
/*
* 404
*/
else
{
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
}