Basis
This commit is contained in:
+14
-13
@@ -2,19 +2,20 @@
|
||||
// Namespaces
|
||||
use Pecee\SimpleRouter\SimpleRouter;
|
||||
use Pecee\Http\Request;
|
||||
// Error handling redirects
|
||||
// Error handling
|
||||
SimpleRouter::error(function (Request $request, \Exception $exception) {
|
||||
switch ($exception->getCode()) {
|
||||
// Page not found
|
||||
case 404:
|
||||
redirect('/phpCourse/exam/not-found', 404);
|
||||
}
|
||||
response()->httpCode($exception->getCode())->json(["message" => $exception->getMessage()]);
|
||||
});
|
||||
//404
|
||||
SimpleRouter::get('/not-found', [Pages\NotFound\NotFound::class, "render"]);
|
||||
//Index
|
||||
SimpleRouter::get('/', function () {
|
||||
return 'Hello world';
|
||||
// Index
|
||||
SimpleRouter::all("/", function () {
|
||||
redirect("docs", 301);
|
||||
});
|
||||
// Login/Logout
|
||||
SimpleRouter::post("/login", [Api\Login\Login::class, "post"]);
|
||||
SimpleRouter::post("/logout", [Api\Logout\Logout::class, "post"]);
|
||||
// User
|
||||
SimpleRouter::group(["middleware" => \Api\Auth\Auth::class], function () {
|
||||
SimpleRouter::get("/user/{id}", function ($userID) {
|
||||
echo "USER ENDP $userID";
|
||||
});
|
||||
});
|
||||
//API
|
||||
SimpleRouter::get("/api/login", [Api\Login\Login::class, 'post']);
|
||||
|
||||
Reference in New Issue
Block a user