Api gateway kong learning: (two) configure server and route

Configure Api gateway:

1. Configure the server

Official website link: https://docs.konghq.com/1.0.x/admin-api/#upstream-objects

 Example: (192.168.0.30 is the ip address of my Kong gateway)

curl -i -X POST \
  --url http://localhost:8001/services/ \
  --data 'name=baidu_general_service_6' \
  --data 'url=https://aip.baidubce.com'

2. Configure route

 

 

Example: (192.168.0.30 is the ip address of my Kong gateway)

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. Test:


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'

Will return the results of Baidu text recognition

Guess you like

Origin blog.csdn.net/kh815/article/details/85319289