cutplane1/u-router

Finished router.

1.3.2 2023-12-18 14:02 UTC

This package is auto-updated.

Last update: 2025-01-06 15:21:17 UTC


README

<?php

require "vendor/autoload.php";

$router = new Cutplane1\URouter();

$router->not_found(function() {
    http_response_code(404);
    echo "<h1>404 Not Found</h1>";
});

$router->middleware(function() {
    header('Content-Type: application/json; charset=utf-8');
});

$router->get("/", function() {
    echo json_encode(["hello" => "world"]);
});

$router->get("/<int>", function($id) {
    echo json_encode(["id" => $id]);
});

$router->dispatch();