I read many post regarding new concept about api routing. I understood that api routing is used for mobile platforms but is there code level difference between them
In RouteServiceProvider
i can see
/**
* 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');
});
}
As per this web route uses
These routes all receive session state, CSRF protection, etc.
api route
These routes are typically stateless.
My question is
What does it mean
stateless
in api route ?Web routing uses
session state
,CSRF protection
. Does it mean api routing is not using session state, CSRF protection ?Laravel 5.3 uses seperate
web
andapi
routing, is there any advantages ?