When you use reply method:

let resp = reply('hello world')

It actually return an response object.

By using response object, you can modiy the response's status code, header, cookie, type and so on...

server.route({
method: 'GET',
path: '/',
handler: function(request, reply) {
let resp = reply('hello world')
resp.code(418) // set status code to 418
resp.type('text/plain') // set type to text/plain
resp.header('hello', 'world') // set header to hello: world
resp.state('hello', 'world') // set cookie to hello=world
}

response object is chainable:

server.route({
method: 'GET',
path: '/',
handler: function(req, reply){
reply('hello world')
.code(418)
.type('text/plain')
.header('hello', 'world')
-state('hello', 'world')
}
})

[Hapi.js] Using the response object的更多相关文章

  1. 【前端】js中new和Object.create()的区别

    js中new和Object.create()的区别 var Parent = function (id) { this.id = id this.classname = 'Parent' } Pare ...

  2. js动态参数作为Object的属性取值

    js动态参数作为Object的属性取值var myObj = {"a":1,"b":2};var a = 'a';myObj[a] 就可以获取到 属性a的值了

  3. JS中==、===和Object.is()的区别

    JS中==.===和Object.is()的区别 首先,先粗略了解一下这三个玩意儿: ==:等同,比较运算符,两边值类型不同的时候,先进行类型转换,再比较: ===:恒等,严格比较运算符,不做类型转换 ...

  4. js中关于new Object时传参的一些细节分析

    1, 参数是一个对象,核心js对象(native ECMAScript object)或宿主对象(host object),那么将直接返回该对象. 其生成的对象构造器仍然是所传参数对象的构造器.这样造 ...

  5. js arrow function return object

    js arrow function return object bug filterData: { type: Object, default: () => {}, required: true ...

  6. [Hapi.js] Replying to Requests

    hapi's reply interface is one of it's most powerful features. It's smart enough to detect and serial ...

  7. [转]Build An Image Manager With NativeScript, Node.js, And The Minio Object Storage Cloud

    本文转自:https://www.thepolyglotdeveloper.com/2017/04/build-image-manager-nativescript-node-js-minio-obj ...

  8. [Hapi.js] Managing State with Cookies

    hapi has built-in support for parsing cookies from a request headers, and writing cookies to a respo ...

  9. [Hapi.js] Request Validation with Joi

    hapi supports request validation out of the box using the joi module. Request path parameters, paylo ...

随机推荐

  1. poj 3009 Curling 2.0 (dfs )

    Curling 2.0 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11879   Accepted: 5028 Desc ...

  2. 利用扩展双屏技术及Chrome浏览器,高速剖析优秀网页Div及CSS构成,并高效实现原型创作

    作为一个Web前台设计人员,应该充分利用可利用的硬件条件及专业的软件工具,迅速进入到高效氛围其中.实践中,我们能够利用扩展桌面双屏技术及Chrome浏览器高速剖析优秀网页Div及CSS构成,并高速实现 ...

  3. 使用apktool解包和打包apk

    使用apktool解包和打包apk 下载apktool工具 解包 apktool d xxx.apk -f 植入代码 使用apktool解包要植入代码的apk(下面称为A), 使用apktool解包包 ...

  4. TableView数据源方法的执行顺序

    UITableView显示数据的过程 1.调用一次tableView:numberOfRowsInSection:方法确定行数 2.调用多次tableView:heightForRowAtIndexP ...

  5. puppet 4.4 System Requirements

    puppet是linux下自动部署管理工具,有apply,agent/server两种模式,安装后默认为agent/server模式. apply模式下,每台机器均有自己的catalog文件,如果需要 ...

  6. C#在局域网中连接Liunx上的MySql数据库

    前期准备工作: 我所用的平台是VS2010和Ubuntu 14.04.3  LTS 一.由于MySql并没有集成在VS2010中所以要先安装MySQL Connector Net 6.9.8连接工具, ...

  7. Parser Error Message: Access is denied【转】

    PRB: Access Denied Error When You Make Code Modifications with Index Services Running View products ...

  8. 3 linux、windows环境---路径分隔符不同导致的问题

    问题:通常在eclipse,IntelliJ IDEA等进行代码编写时,程序中用到路径通常采用/job/test.properties或D:/job/test.properties等是形式作为文件路径 ...

  9. 为什么要用Math.sqrt(i)方法

    java 练习题 判断 101-200 之间有多少个素数,并输出所有素数 public class Prime { public static int count = 0; public static ...

  10. 虚拟机安装centos

    linux安装 鉴于国内大多数服务器都使用的redhat系列作为操作系统,centos又是redhat的免费版本,所以可以学习一下.因为另一台古董电脑已经装了linuxmint,虽然也可以安装虚拟机, ...