博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Response
阅读量:6839 次
发布时间:2019-06-26

本文共 1275 字,大约阅读时间需要 4 分钟。

Response

This improved Response API, able to simplify the Framework's Response management. Practically, is now possible to do in a Controller Method:

// Create a Response instance with string contentreturn Response::make(json_encode($user)); // Create a Response instance with a given status return Response::make('Not Found', 404); // Create a Response with some custom headers return Response::make(json_encode($user), 200, array('header' => 'value')); // Create a response instance with JSON return Response::json($data, 200, array('header' => 'value')); // Create a 404 response with data (will be directly obtained a shiny themed Error Page) return Response::error('404', array('message' => 'Not Found'));

It is also possible to use those Response instance in the Route Filters, case when the given Response will be sent to the browser and the further processing will be skipped.

To note that Response class was moved to Core considering as being now a vital part of Framework, for its properly work, and not an (optional) Helper.

The new Response API permit further simplifications on Routing. For example, the command Response::error()is quite capable to display a themed/templated Error Page, without the help of an additional "Error Controller" or other "callbacks".

转载地址:http://mlqkl.baihongyu.com/

你可能感兴趣的文章
随机森林案例分析:德国银行信贷风险分析
查看>>
ant读书之使用ant进行java开发--第二章
查看>>
Glib实例学习(5)平衡二叉树
查看>>
【整理】OC中常用的关于时间格式的转换
查看>>
关于升级 xcode8
查看>>
Spring boot返回JSON类型响应及Content-Type设置
查看>>
递归详解
查看>>
CSS3 filter:drop-shadow滤镜与box-shadow区别
查看>>
windows7+Apache2.2+PHP5.4.29 环境搭建
查看>>
常用快捷键
查看>>
Spring AOP动态代理-切面
查看>>
Spring整合JMS(四)——事务管理
查看>>
C#中获取当前应用程序的路径及环境变量
查看>>
ThinkPHP5.0中Redis的使用和封装
查看>>
使用dwz框架搭建网站后台
查看>>
为什么很多人喜欢把软件装在D盘,而不是系统盘C
查看>>
把json对象串转换成map对象
查看>>
十字消源码分享(基于libgdx开发)
查看>>
看到OSC有一期是:“OSChina 第 37 期高手问答 —— 消息队列服务”
查看>>
Quasar Akka Vertx Norbert 比较
查看>>