You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: demo/index.php
+36-1
Original file line number
Diff line number
Diff line change
@@ -19,14 +19,49 @@
19
19
echo'404, route not found!';
20
20
});
21
21
22
+
// custom 404
23
+
$router->set404('/test(/.*)?', function () {
24
+
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
25
+
echo'<h1><mark>404, route not found!</mark></h1>';
26
+
});
27
+
28
+
$router->set404('/api(/.*)?', function() {
29
+
header('HTTP/1.1 404 Not Found');
30
+
header('Content-Type: application/json');
31
+
32
+
$jsonArray = array();
33
+
$jsonArray['status'] = "404";
34
+
$jsonArray['status_text'] = "route not defined";
35
+
36
+
echojson_encode($jsonArray);
37
+
});
38
+
22
39
// Before Router Middleware
23
40
$router->before('GET', '/.*', function () {
24
41
header('X-Powered-By: bramus/router');
25
42
});
26
43
27
44
// Static route: / (homepage)
28
45
$router->get('/', function () {
29
-
echo'<h1>bramus/router</h1><p>Try these routes:<p><ul><li>/hello/<em>name</em></li><li>/blog</li><li>/blog/<em>year</em></li><li>/blog/<em>year</em>/<em>month</em></li><li>/blog/<em>year</em>/<em>month</em>/<em>day</em></li><li>/movies</li><li>/movies/<em>id</em></li></ul>';
0 commit comments