delete() public static method

注册DELETE路由
public static delete ( string $rule, string $route = '', array $option = [], array $pattern = [] ) : void
$rule string 路由规则
$route string 路由地址
$option array 路由参数
$pattern array 变量规则
return void
Beispiel #1
0
 public function testRegister()
 {
     Route::get('hello/:name', 'index/hello');
     Route::get(['hello/:name' => 'index/hello']);
     Route::post('hello/:name', 'index/post');
     Route::put('hello/:name', 'index/put');
     Route::delete('hello/:name', 'index/delete');
     Route::any('user/:id', 'index/user');
     $this->assertEquals(['type' => 'module', 'module' => [null, 'index', 'hello']], Route::check('hello/thinkphp'));
     $this->assertEquals(['hello/:name' => ['route' => 'index/hello', 'option' => [], 'pattern' => []]], Route::getRules('GET'));
     Route::register('type/:name', 'index/type', 'PUT|POST');
 }
Beispiel #2
0
 public function testRegister()
 {
     $request = Request::instance();
     Route::get('hello/:name', 'index/hello');
     Route::get(['hello/:name' => 'index/hello']);
     Route::post('hello/:name', 'index/post');
     Route::put('hello/:name', 'index/put');
     Route::delete('hello/:name', 'index/delete');
     Route::patch('hello/:name', 'index/patch');
     Route::any('user/:id', 'index/user');
     $result = Route::check($request, 'hello/thinkphp');
     $this->assertEquals([null, 'index', 'hello'], $result['module']);
     $this->assertEquals(['hello' => true, 'user/:id' => true, 'hello/:name' => ['rule' => 'hello/:name', 'route' => 'index/hello', 'var' => ['name' => 1], 'option' => [], 'pattern' => []]], Route::rules('GET'));
     Route::rule('type1/:name', 'index/type', 'PUT|POST');
     Route::rule(['type2/:name' => 'index/type1']);
     Route::rule([['type3/:name', 'index/type2', ['method' => 'POST']]]);
     Route::rule(['name', 'type4/:name'], 'index/type4');
 }