iCo*_*ers 1 php laravel laravel-5.3
关于api路由的新概念,我阅读了很多帖子.我知道api路由用于移动平台,但它们之间存在代码级别差异
在RouteServiceProvider我能看到
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
});
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::group([
'middleware' => 'api',
'namespace' => $this->namespace,
'prefix' => 'api',
], function ($router) {
require base_path('routes/api.php');
});
}
Run Code Online (Sandbox Code Playgroud)
根据此Web路由使用
这些路由都接收会话状态,CSRF保护等.
api路线
这些路线通常是无国籍的.
我的问题是
statelessapi路线是什么意思?
Web路由使用 session state,CSRF protection.这是否意味着api路由不使用会话状态,CSRF保护?
Laravel 5.3使用单独web和api路由,有什么优点吗?
statelessapi路线是什么意思?这意味着服务器不会在请求之间保存客户端"状态".以下是关于REST的几个词究竟什么是RESTful编程?
session state,CSRF protection.这是否意味着api路由不使用会话状态,CSRF保护?一切皆有可能但不是必需的.您仍然可以使用会话等,但这是违反REST原则的.
web和api路由,有什么优点这只是为了您的方便.在Laravel 5.2中,您需要为['web']或['api']等路由指定中间件,但不再需要它.在存储在单独文件中的5.3路由中,指定不需要的路由中间件.
| 归档时间: |
|
| 查看次数: |
2197 次 |
| 最近记录: |