-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdispatch.php
More file actions
42 lines (27 loc) · 1.04 KB
/
dispatch.php
File metadata and controls
42 lines (27 loc) · 1.04 KB
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
<?php
// load Tonic
require_once '/usr/local/tonic/src/Tonic/Autoloader.php';
$config = array(
'load' => array('/usr/local/tonic/*.php', './src/*.php'), // load example resources
#'mount' => array('Tyrell' => '/nexus'), // mount in example resources at URL /nexus
#'cache' => new Tonic\MetadataCacheFile('/tmp/tonic.cache') // use the metadata cache
#'cache' => new Tonic\MetadataCacheAPC // use the metadata cache
);
$app = new Tonic\Application($config);
#echo $app; die;
$request = new Tonic\Request();
#echo $request; die;
try {
$resource = $app->getResource($request);
#echo $resource; 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();