【发布时间】:2017-02-28 12:09:37
【问题描述】:
我阅读了很多关于 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');
});
}
按照这个网络路由使用
这些路由都接收会话状态、CSRF 保护等。
api路由
这些路由通常是无状态的。
我的问题是
api路由中
stateless是什么意思?Web 路由使用
session state、CSRF protection。是不是说api路由没有使用会话状态、CSRF保护?Laravel 5.3 使用单独的
web和api路由,有什么优势吗?
【问题讨论】:
标签: php laravel laravel-5.3