Laravel-路线GET | HEAD [英] Laravel - Routes GET|HEAD

查看:110
本文介绍了Laravel-路线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类获取的,Laravelurl添加了这两种方法,这意味着使用get方法注册的这些url可以使用GETHEAD 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 urls registered using getmethod 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆