打开bootstrap/app.php,取消下面两段代码的注释,

$app->middleware([
   App\Http\Middleware\ExampleMiddleware::class
]);

$app->routeMiddleware([
   'auth' => App\Http\Middleware\Authenticate::class,
]);

打开router/web.php,加入以下路由代码,

$app->group(['middleware' => 'auth'], function ($app){
	$app->get('hello', function() {
	    echo 'hello, world';
	});
});

访问 域名/hello,显示 hello, world。

 

https://laravel-china.org/docs/lumen/5.2/authentication/1863

相关文章:

  • 2022-01-13
  • 2022-01-11
  • 2022-02-11
  • 2021-11-11
  • 2021-07-25
  • 2021-04-07
  • 2021-09-06
猜你喜欢
  • 2021-07-20
  • 2021-07-08
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案