laravel 配置路由 api和web定义的路由的区别详解
1、路由经过中间件方面不同
打开kerenl.php就可以看到区别
protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ], 'api' => [ 'throttle:60,1', 'bindings', ], ];
2、路径不一样
在web.php写的路由是这样的
eg:http://quan.cms/backend/admin/add
在api.php写的路由需要加上XXX/api/路由地址,相当于在web.php的基础上加了一层api
eg:http://quan.cms/api/backend/admin/add
相关推荐
wangxuekuan 2020-11-24
xuedabao 2020-11-19
hjr 2020-10-21
sjun0 2020-11-12
bestallen 2020-08-17
80143853 2020-08-17
Tplinkly 2020-08-15
dingyahui 2020-08-12
JiangMengYa 2020-07-30
BingGoGo技术 2020-07-25
前端小白 2020-07-19
JudeJoo 2020-07-14
bowean 2020-07-05
82344699 2020-07-05
85423468 2020-06-26
tuxlcsdn 2020-06-21
独行者0 2020-06-20