示例#1
0
 function testAddCustomRoute()
 {
     Route::addRoute('get', '/test_routes', function ($val) {
         return $val;
     });
     $this->assertEquals(sizeof(Route::getRoutes()), 1);
     $this->assertEquals(Route::getRoutes()[0]['path'], '/test_routes');
     $callback = Route::getRoutes()[0]['callback'];
     $this->assertEquals($callback(42), 42);
 }
示例#2
0
 private function addCustomRoutes()
 {
     foreach (Route::getRoutes() as $route) {
         $this->_router->respond($route['method'], $route['path'], $route['callback']);
     }
 }
示例#3
0
<?php

/*
 * This is where you add your own custom routes
 */
use Cymbaline\Route;
Route::addRoute('get', '/hello/[:id]', function ($request) {
    $controller = new UserController();
    $controller->test_custom_route($request->id);
});