koahub-body-res

koahub body res

Format koa's respond json.

Installation

$ npm install koahub-body-res

Use with koa

var app = require('koa')();
var koaRes = require('koahub-body-res');
app.use(koaRes());
 
this.data = 'This is a body';
this.msg = 'This is a msg';
this.go = 'This is a go url';
 
output
 
this.body = {
    code: 200,
    data: 'This is a body',
    msg: 'This is a msg'
}
 
this.body = {
    code: 200,
    data: 'This is a body',
    msg: 'This is a msg',
    go: 'This is a go url'
};
 

官网:http://js.koahub.com

基于 Koa平台Node.js开发的KoaHub.js的输出json到页面代码的更多相关文章

  1. 基于 Koa平台Node.js开发的KoaHub.js的控制器,模型,帮助方法自动加载

    koahub-loader koahub-loader是基于 Koa平台Node.js开发的KoaHub.js的koahub-loader控制器,模型,帮助方法自动加载 koahub loader I ...

  2. 基于 Koa平台Node.js开发的KoaHub.js连接打印机的代码

    最近好多小伙伴都在做微信商城的项目,那就给大家分享一个基于 Koa.js 平台的 Node.js web 开发的框架连接微信易联云打印机接口的代码,供大家学习.koahub-yilianyun 微信易 ...

  3. 基于 Koa平台Node.js开发的KoaHub.js获取/设置会话功能代码

    koa-session2 Middleware for Koa2 to get/set session use with custom stores such as Redis or mongodb ...

  4. 基于 Koa平台Node.js开发的KoaHub.js的静态服务器重写和索引代码

    koa-static-server Static file serving middleware for koa with directory, rewrite and index support k ...

  5. 基于 Koa平台Node.js开发的KoaHub.js的模板引擎代码

    koahub-handlebars koahub-handlebars koahub handlebars templates Installation $ npm install koahub-ha ...

  6. 基于 Koa平台Node.js开发的KoaHub.js的跳过组件代码

    koahub-skip koahub skip middleware koahub skip Conditionally skip a middleware when a condition is m ...

  7. 基于LBS平台的iOS开发

    LBS,即Location Based Services,基于位置服务,用于定位.导航等功能,比如地图应用.订外卖等的app就需要这个功能. 在这里我使用的是高德LBS开放平台,地址:http://l ...

  8. Android 基于Bmob平台数据管理常用方法整理

    最近想搞一下基于Bmob平台的应用开发,发现确实挺方便的,很好的解决了服务器后台部署的难题, 但是也有一些弊端,数据架构的可扩展性不强,做一些数据结构简单的应用还是可以的. package com.b ...

  9. KoaHub平台基于Node.js开发的Koa 连接支付宝插件代码信息详情

    KoaHub平台基于Node.js开发的Koa 链接支付宝插件代码信息详情 easy-alipay alipay payment & notification APIs easy-alipay ...

随机推荐

  1. HDU-1996-汉诺塔VI

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1996 其实它就是求移动的所有可能,也就是n个盘子摆在三个塔上的任何可能的种数.可以这么思考这个问题:n ...

  2. MyEclipse 中 添加 js自动完成模版

    MyEclipse 中 添加 js自动完成模版: window>preference>MyEclipse>Files and Editors>JavaScript>Edi ...

  3. 如何在asp.net页面使用css和js

    一.如何在asp.net页面中使用css1.可以直接写在需要样式控制的控件里 例如:<div style="border:#ff6100 1px solid">< ...

  4. bootstrap 基础表单 内联表单 横向表单

    bootstrap 基础表单 内联表单 横向表单 <!DOCTYPE html> <html> <head> <title></title> ...

  5. spring的value,null标签

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://ww ...

  6. Spring MVC DispatcherServlet绑定多种URL

    需要学习的内容: http://my.oschina.net/shishuifox/blog/215617 当前的处理方式,在web.xml中配置: <servlet> <servl ...

  7. Canvas createImageData

    createImageData() 方法创建新的空白 ImageData 对象.新对象的默认像素值 transparent black. 对于 ImageData 对象中的每个像素,都存在着四方面的信 ...

  8. promise/bluebird源码

    本作品采用知识共享署名 4.0 国际许可协议进行许可.转载保留声明头部与原文链接https://luzeshu.com/blog/bluebirdsource 本博客同步在http://www.cnb ...

  9. JavaScript字符集编码与解码

    一.字符集 1)字符与字节(Character) 字符是各种文字和符号的总称,包括乱码:一个字符对应1~n个字节,一字节对应8位,每位用0或1表示. 2)字符集(Character Set) 字符集是 ...

  10. iOS深入学习之Weak关键字介绍

    iOS深入学习之Weak关键字介绍 前言 从大二的开始接触OC就用到了weak属性修饰词,但是当时只是知道如何去用这个关键字:防止循环引用.根本没有深入地去了解它. 在刚来北京的时候面试过程中也常常考 ...