1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /**
- * Created by benzhan on 15/8/13.
- */
- var Controller = require('./../framework/Controller.js');
- var util = require('util');
- var http = require('http');
- var querystring = require("querystring");
- util.inherits(AdminController, Controller);
- var prototype = AdminController.prototype;
- /**
- * @type {AdminController}
- */
- var that;
- function AdminController() {
- Controller.apply(this, arguments);
- that = this;
- }
- /**
- * 发送测试环境消息
- */
- AdminController.prototype.actionSendTestMsg = function(args) {
- var host = "test.api.oxzj.net";
- _sendMsg(this._req, this._res, host);
- }
- /**
- * 发送正式环境消息
- */
- AdminController.prototype.actionSendFormalMsg = function(args) {
- var host = "sns.api.ouj.com";
- _sendMsg(this._req, this._res, host);
- }
- function _sendMsg(req, res, host) {
- var queryStr = querystring.stringify(req.query);
- var sreq = http.request({
- host: host, // 目标主机
- path: '/userMessage/add.do?' + queryStr, // 目标路径
- method: req.method // 请求方式
- }, function(sres){
- sres.pipe(res);
- sres.on('end', function(){
- });
- });
- if (/POST|PUT/i.test(req.method)) {
- req.pipe(sreq);
- } else {
- sreq.end();
- }
- }
- module.exports =AdminController;
|