-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdispatch.php
More file actions
43 lines (28 loc) · 929 Bytes
/
Copy pathdispatch.php
File metadata and controls
43 lines (28 loc) · 929 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
38
39
40
41
42
43
<?php
// load autoloader (delete as appropriate)
if (@include(__DIR__.'/lib/Tonic/Autoloader.php')) { // use Tonic autoloader
new Tonic\Autoloader('resources'); // add another namespace
}
$config = array(
'load' => array(
__DIR__.'/resources/*.php', // load resources
)
);
$app = new Tonic\Application($config);
#echo $app; die;
$request = new Tonic\Request();
#echo $request; die;
try {
$resource = $app->getResource($request);
#echo $resources; die;
$response = $resource->exec();
} catch (Tonic\NotFoundException $e) {
$response = new Tonic\Response(404, $e->getMessage());
} catch (Tonic\UnauthorizedException $e) {
$response = new Tonic\Response(401, $e->getMessage());
$response->wwwAuthenticate = 'Basic realm="My Realm"';
} catch (Tonic\Exception $e) {
$response = new Tonic\Response($e->getCode(), $e->getMessage());
}
#echo $response;
$response->output();