StrongLoop microgateway使用总结(一)
源码引入
github地址https://github.com/strongloop/microgateway
不使用manage管理工具
拉取源码
git clone https://github.com/strongloop/microgateway
npm install
安装依赖项在根目录创建 app 文件,用于存放网关api
增加 env.yaml 文件
DIR_CONFIG: "./app" // 监测app文件下的所有api操作 PORT: 5000 // 网关启动端口 ... // 其他配置请自行添加
增加 id_rsa 文件,存放的为ssh密钥
简单例子:
在app下创建 sample 文件,在sample文件下创建 sample_1.0.0 文件
# sample_1.0.0.yaml # info: version: 1.0.0 title: sample description: sample laptop yaml basePath: /sample swagger: '2.0' paths: /echo: get: responses: '200': description: 200 OK x-ibm-configuration: assembly: execute: - javascript: title: write a small json object source: | message.body = { text : 'Hello World' }; schemes: - http
启动网关
node .
此时网关便启动,执行
curl http://localhost:5000/sample/echo
发现启动成功返回: { text : 'Hello World' }