Skip to content

cutplane1/u-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

u-router

<?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();