zoukankan      html  css  js  c++  java
  • Response

    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 content
    return 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".

  • 相关阅读:
    Ubuntu VIM下实现python自动缩进
    认识Python和基础知识
    Linux常用服务器搭建
    VIM常用命令
    Linux基础
    LINUX操作系统VIM的安装和配置
    Ubuntu 16.04下安装搜狗输入法
    Ubuntu 16.04下sublime text3安装
    Ubuntu软件安装与卸载
    present(模态)实现出push的效果
  • 原文地址:https://www.cnblogs.com/chunguang/p/5643020.html
Copyright © 2011-2022 走看看