配置Api网关:
1.配置server
官网链接:https://docs.konghq.com/1.0.x/admin-api/#upstream-objects
示例:(192.168.0.30为我的kong网关的ip地址)
curl -i -X POST \
--url http://localhost:8001/services/ \
--data 'name=baidu_general_service_6' \
--data 'url=https://aip.baidubce.com'
2.配置route
示例: (192.168.0.30为我的kong网关的ip地址)
curl -i -X POST \
--url http://localhost:8001/services/baidu_general_service_6/routes \
--data 'protocols[]=https' \
--data 'hosts[]=192.168.0.30' \
--data 'paths[]=/cc'
3.测试:
curl -i -k 'https://192.168.0.30:8443/cc/rest/2.0/ocr/v1/general?access_token=24.6ff27286b3d73594a02900e77d2002df.2592000.1547547820.282335-15178195' -H 'Content-Type:application/x-www-form-urlencoded' --data 'url=https%3A%2F%2Fss3.bdstatic.com%2F70cFv8Sh_Q1YnxGkpoWK1HF6hhy%2Fit%2Fu%3D300223806%2C1150068993%26fm%3D26%26gp%3D0.jpg'
会返回百度文字识别的结果