Laravel-路线GET | HEAD [英] Laravel - Routes GET|HEAD
问题描述
当我执行php artisan routes
时,我的应用程序的GET
请求具有一个|HEAD
. |HEAD
的目的是什么?
When I do php artisan routes
, the GET
request of my app has a |HEAD
. What is the purpose of having |HEAD
?
Routes.php
+--------+----------------------------------+------------------------------+--------------------------------------+----------------+---------------+
| Domain | URI | Name | Action | Before Filters | After Filters |
+--------+----------------------------------+------------------------------+--------------------------------------+----------------+---------------+
| | GET|HEAD / | home | HomeController@home | | |
| | GET|HEAD user/{username} | profile-user | ProfileController@user | | |
| | GET|HEAD account/change-password | account-change-password | AccountController@getChangePassword | auth | |
| | GET|HEAD asset/encode-file/{id} | encode-file | EncodeController@getEncode | auth | |
| | GET|HEAD asset/edit-file/{id} | edit-file | AssetController@getEdit | auth | |
| | GET|HEAD asset/delete-file/{id} | delete-file | AssetController@deleteDestroy | auth | |
| | GET|HEAD asset/upload-file-form | upload-file-form | AssetController@getUploadCreate | auth | |
| | GET|HEAD asset/library | asset-library | AssetController@getAssetLib | auth | |
| | GET|HEAD account/sign-out | account-sign-out | AccountController@getSignOut | auth | |
| | GET|HEAD account/activate/{code} | account-activate | AccountController@getActivate | guest | |
| | GET|HEAD account/forgot-password | account-forgot-password | AccountController@getForgotPassword | guest | |
| | GET|HEAD account/recover/{code} | account-recover | AccountController@getRecover | guest | |
| | GET|HEAD account/sign-in | account-sign-in | AccountController@getSignIn | guest | |
| | GET|HEAD account/create | account-create | AccountController@getCreate | guest | |
+--------+----------------------------------+------------------------------+--------------------------------------+----------------+---------------+
推荐答案
当您使用Route::get()
方法为您的站点/应用程序添加路由时,以下功能是从Laravel'
的Illuminate\Routing\Router.php
类获取的,Laravel
为url
添加了这两种方法,这意味着使用get
方法注册的这些url
可以使用GET
和HEAD
HTTP
方法以及
Following function is taken from the Laravel'
s Illuminate\Routing\Router.php
class, when you use Route::get()
method to add a route for your site/application, Laravel
adds both methods for the url
, it means that, these url
s registered using get
method could be accessed using both GET
and HEAD
HTTP
method, and HEAD is just another HTTP
verb/method, used for making a HEAD
request.
/**
* Register a new GET route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @return \Illuminate\Routing\Route
*/
public function get($uri, $action)
{
return $this->addRoute(array('GET', 'HEAD'), $uri, $action);
}
这篇关于Laravel-路线GET | HEAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!