最近在做微服务相关产品,其中需要有API网关相关产品,虽然早有研究过API网关产品TYK,但是感觉其太重,想起之前研究开源BI产品saiku的时候,记得其有NodeJS的代理代码,于是看了下,颇有启发,略微修改了一些,拿出来跟大家分享下,虽然简单,不可用于生产,但是对于学习还是不错的
{"name": "SmartHttpProxy","description": "An simplest Http Proxy","version": "0.0.1","author": "liuyg@liuyingguang.cn","license": {"type": "Apache License Version 2"},"main": "server.js","scripts": {"start": "node server.js 8088 127.0.0.1 80 / "},"dependencies": {"express": "~4.13.4"}}
/*** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either e
最近参与前端开发任务,用到nodejs,虽然公司同事都用webstorm,自己也用了,但是总感觉不顺手,可能是常年使用eclipse开发有关(这里不讨论最佳开发工具,自己顺手才是王道),于是自己想要使用eclipse开发nodejs项目,想到之前听说的nodeclipse,就去官网看了下,安装步奏还是挺方便的,安装后初步试用了下,感觉挺顺手的
1、安装nodejs
2、安装jdk,配置eclipse,这里我用的是eclipse 4.5.2
3、下载nodeclipse离线安装包:
http://nchc.dl.sourceforge.net/project/nodeclipse/update-site-archive/org.nodeclipse.site-1.0.2-201509250223.zip
或者
http://pan.baidu.com/s/1dFiF7IL
4、安装nodeclipse,help-->Install New Software,如下图选择下载的压缩包
选择插件:
5、完成以上步奏即完成了安装
更多安装方式还请参考如下地址:
http://www.nodeclipse.org/updates/
错误信息:ERROR: { [Error: socket hang up] code: 'ECONNRESET' }
分析原因:由于某种原因,导致http目标地址建立socket连接的时候出错
错误解决:经过对比查找,发现我这里nodejs项目中有对中间件“body-parser”的使用,将其去除,则没有问题了
还有其他一些原因,这里暂时没有遇到,就不多做解释了,