dongwu8064 2016-03-02 21:19
浏览 257
已采纳

方法名称作为Laravel API中的POST参数

I want to make Laravel RESTful API and also i have something that can send request to www but there is problem - this THING can send only GET and POST. Is there way to configure Laravel to know that i sent method name as a parameter for ex. in _method parameter and redirect to proper Route (i prefer making Route::resource so that's why i'm asking)?

  • 写回答

1条回答 默认 最新

  • dtqf81594 2016-03-03 05:29
    关注

    This is called Method Tunneling through POST.

    In many scenarios clients are limited to the HTTP GET and POST methods only. In order to help work-around this limitation, RESTful servers can support method tunneling through POST. The methods that can be executed through tunneling are MERGE, PUT and DELETE.

    To issue a request with method tunneling a client sets up a request with body and headers as needed, but uses POST as the HTTP method instead of the actual required one. It then adds one more header, "X-HTTP-Method", and gives it the value MERGE, PUT or DELETE.

    Servers must check if POST requests have the X-HTTP-Method header set to one of the valid values and if so execute the rest of the request as if the header value was the actual HTTP method for it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog