api中台

以数据为中心,发展信息化 以数据为主线,以技术为支撑。开展生产生活

建议资源访问开启双域名通路。[l-xxx,p-xxx] 一个执行私有地址,一个指向公网地址

名称域名备注
nocoDBl-noco.ouqiyj.com本地多维表格-(hr通知)

AI智能底座

AI 光有大脑不行要有手去操作系统。调用企业资源。没有手脚的AI还是需要人来执行实际的操作工作。

api服务 就提供了企业内所有资源的使用接口,通过对接到各应用系统内的接口来完成一系列的工作。

大致IT技术架构 ()

工具箱(工具的局限,非思维局限)

  • kong来做统一入口(前台归集资源)

  • node-red即时简单的iot (调度api )

  • python自研业务逻辑 (jsonrpc 服务api)

  • 多维表格-简易人机接口 (缺少交互按钮)

  • Apifox/hoppscotch (单步验证)

kong适合api请求管理和域名映射管理 (应用代理)

业务转发++

nocoDB

curl -X POST http://127.0.0.1:8001/services/ \
  --header "Content-Type: application/json" \
  --data '{
    "name": "nocodb-service",
    "url": "http://192.168.0.123:8123"
  }'
  
curl -X POST http://127.0.0.1:8001/services/nocodb-service/routes \
  --header "Content-Type: application/json" \
  --data '{
    "name": "nocodb-service-route",
    "hosts": ["l-noco.ouqiyj.com"],
    "strip_path": false
  }'

Node-Red

curl -X POST http://127.0.0.1:8001/services/ \
  --header "Content-Type: application/json" \
  --data '{
    "name": "nodered-msg-service",
    "url": "http://192.168.11.144:1880"
  }'
  
curl -X POST http://127.0.0.1:8001/services/nodered-msg-service/routes \
  --header "Content-Type: application/json" \
  --data '{
    "name": "nodered-msg-service-route",
    "hosts": ["l-nodered-msg.ouqiyj.com"],
    "strip_path": false
  }'

简单转发

  1. 创建一个 Service:代表您的后端服务。
  2. 创建一个 Route:定义匹配客户端请求的规则。

curl -X POST http://127.0.0.1:8001/services/ \
  --header "Content-Type: application/json" \
  --data '{
    "name": "nodered-service",
    "url": "http://192.168.11.144:1880"
  }'


curl -X POST http://127.0.0.1:8001/services/nodered-service/routes \
  --header "Content-Type: application/json" \
  --data '{
    "name": "nodered-tget-route",
    "paths": ["/nodered"]
  }'

注意 公开访问路径是 /nodered/tget 后端服务路径是 /tget

指定来请求主机

curl -X POST http://127.0.0.1:8001/services/ \
  --header "Content-Type: application/json" \
  --data '{
    "name": "another-service",
    "url": "http://192.168.0.123:8001"
  }'
  
  curl -X POST http://127.0.0.1:8001/services/another-service/routes \
  --header "Content-Type: application/json" \
  --data '{
    "name": "another-9000-route",
    "paths": ["/admin"], 
    "hosts": ["192.168.0.123:9099", "127.0.0.1:8000","*:1234"]
  }'

erp地址转发


curl -X POST http://127.0.0.1:8001/services/ \
  --header "Content-Type: application/json" \
  --data '{
    "name": "k3cloud-service",
    "url": "http://192.168.0.48:80"
  }'
  
  
curl -X POST http://127.0.0.1:8001/services/k3cloud-service/routes \
  --header "Content-Type: application/json" \
  --data '{
    "name": "k3cloud-route",
    "paths": ["/k3cloud"],
    "strip_path": false
  }'

路径重写 (变路径)

curl -X POST http://127.0.0.1:8001/services/k3cloud-service/routes \
  --header "Content-Type: application/json" \
  --data '{
    "name": "oq-erp-route",
    "paths": ["/oq-erp"],
    "strip_path": false
  }'
  
  
  curl -X POST http://127.0.0.1:8001/routes/oq-erp-route/plugins \
  --header "Content-Type: application/json" \
  --data '{
    "name": "request-transformer",
    "config": {
      "replace": {
        "uri": "/k3cloud"
      }
    }
  }'

转发到群辉

路径剥离

curl -X POST http://127.0.0.1:8001/services/ \
  --header "Content-Type: application/json" \
  --data '{
    "name": "yynas-service",
    "url": "http://z4nas.17121.top:5000"
  }'
  
  
  curl -X POST http://127.0.0.1:8001/services/yynas-service/routes \
  --header "Content-Type: application/json" \
  --data '{
    "name": "yynas-route",
    "paths": ["/yynas"],
    "strip_path": true
  }'

域名转发

curl -X POST http://127.0.0.1:8001/services/ \
  --header "Content-Type: application/json" \
  --data '{
    "name": "yynas-domain-service",
    "url": "http://z4nas.17121.top:5000"
  }'
  
curl -X POST http://127.0.0.1:8001/services/yynas-domain-service/routes \
  --header "Content-Type: application/json" \
  --data '{
    "name": "yynas-domain-route",
    "hosts": ["l-yynas.ouqiyj.com"],
    "strip_path": false
  }'

常用转发

web文档


插件

访问量分析

# 全局启用
curl -X POST http://127.0.0.1:8001/plugins/ \
  --header "Content-Type: application/json" \
  --data '{
    "name": "prometheus"
  }'

1小时内访问数据

http://192.168.0.123:8001/metrics