-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
43 lines (32 loc) · 1018 Bytes
/
index.php
File metadata and controls
43 lines (32 loc) · 1018 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
use MatthiasMullie\Minify;
require 'vendor/autoload.php';
$router = new AltoRouter();
$router->setBasePath('/fedishare');
$router->map('GET', '/', function() {
header("Location: https://fedibuzzer.ajr-news.com/");
});
$router->map('GET', '/demo', function() {
require 'api/demo.php';
});
$router->map('GET', '/api/v1/script', function() {
header("Content-type: text/javascript");
$packer = new Minify\JS("script/script.js");
$packed = $packer->minify();
echo $packed;
});
$router->map('GET', '/api/v1/instance/[*:url]', function($url) {
require 'api/getInstanceInfo.php';
});
$router->map('POST', '/api/v1/record', function() {
require 'api/stats.php';
});
// match current request url
$match = $router->match();
// call closure or throw 404 status
if( is_array($match) && is_callable( $match['target'] ) ) {
call_user_func_array( $match['target'], $match['params'] );
} else {
// no route was matched
header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}