-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
66 lines (48 loc) · 1.51 KB
/
index.php
File metadata and controls
66 lines (48 loc) · 1.51 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
require 'vendor/autoload.php';
// require 'predis/autoload.php'; // predis
// Create a new Slim application
$app = new \Slim\App;
// Define your first route
$app->get('/{id}', function ($request, $response, $args)
{
// return $response->write("Welcome to the homepage, " . $args['name'] . "!");
$data = array('userid' => $args['id']);
$newResponse = $response->withJson($data);
return $newResponse;
});
// Define route for ads
$app->get('/resources/{id}', function ($request, $response, $args)
{
// return $response->write("Ad for user: " . $args['id']);
$data = array('userid' => $args['id'], 'resources' => 'Various URLs....');
$newResponse = $response->withJson($data);
return $newResponse;
});
// Define route for ads
$app->get('/redis/{id}', function ($request, $response, $args)
{
// return $response->write("Ad for user: " . $args['id']);
PredisAutoloader::register();
$redis = new PredisClient();
$redis->set('message');
return $response->write($redis);
/*
try {
$redis = new PredisClient(array(
"scheme" => "tcp",
"host" => "172.30.0.13",
"port" => 6379));
$data = array('userid' => $args['id'], 'ad' => 'REDIS');
}
catch (Exception $e) {
$data = array('userid' => 'CRAP', 'ad' => 'ERROR');
}
}
*/
// $data = array('userid' => $args['id'], 'ad' => 'PLURALSIGHT');
$newResponse = $response->withJson($data);
return $newResponse;
});
// Run the application
$app->run();