StrongLoop microgateway使用总结(一)
源码引入
github地址https://github.com/strongloop/microgateway
不使用manage管理工具
拉取源码
git clone https://github.com/strongloop/microgatewaynpm 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' }
本文介绍了如何使用StrongLoop microgateway构建API网关,包括源码拉取、配置及简单的API定义过程。通过实例演示了从环境搭建到网关启动的整个流程。
&spm=1001.2101.3001.5002&articleId=78943674&d=1&t=3&u=c6a9656f9b884c1aad465a6c3c1188f2)
2万+

被折叠的 条评论
为什么被折叠?



