-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.php
More file actions
executable file
·48 lines (39 loc) · 1.29 KB
/
test.php
File metadata and controls
executable file
·48 lines (39 loc) · 1.29 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
<?php
include "Afro.php";
get('/', function($Afro) {
echo "HELLO";
});
get('/countries(.*?)', function($Afro) {
$testData = array();
$Afro->format('json', function() use (&$testData) {
$testData = array(
"mx" => array(
'iso' => 'MX',
'fullName' => 'Mexico'
),
"jm" => array(
'iso' => 'JM',
'fullName' => 'Jamaica'
)
);
});
$lookingFor = strtolower(basename($Afro->params[1], '.json'));
if(isset($testData[$lookingFor])) {
// return json_encode($testData[$lookingFor]);
echo json_encode($testData[$lookingFor]);
}else{
echo json_encode($testData);
}
$Afro->format('csv', function() {
return "iso,fullName\nMX,Mexico\n,JM,Jamaica";
});
if(!$Afro->format) echo "Countries are only available as a JSON format.";
});
get('/hello/(.*?)', function($Afro) {
$Afro->format('json', function($Afro) {
echo json_encode(array('name', $Afro->param(2)));
});
if(!$Afro->format)
echo 'Hello '. $Afro->param(2) . ', it\'s a good day today!';
});
?>