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.

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料