1. Upstreams
curl -X POST http://127.0.0.1:8001/upstreams --data "name=exampleUpstream"
curl -i -X GET --url http://127.0.0.1:8001/upstreams/exampleUpstream
curl -i -X PATCH --url http://127.0.0.1:8001/upstreams/exampleUpstream --data "tags[]=tag1" --data "tags[]=tag2"
curl -i -X DELETE --url http://127.0.0.1:8001/upstreams/exampleUpstream
curl -i -X GET --url http://127.0.0.1:8001/upstreams?size=10
2. Target
curl -X POST http://127.0.0.1:8001/upstreams/exampleUpstream/targets --data "target=www.baidu.com:80" --data "weight=100"
curl -i -X GET --url http://127.0.0.1:8001/upstreams/exampleUpstream/targets/www.baidu.com:80
curl -i -X PATCH --url http://127.0.0.1:8001/upstreams/exampleUpstream/targets/www.baidu.com:80 --data "tags[]=tag1" --data "tags[]=tag2"
curl -i -X DELETE --url http://127.0.0.1:8001/upstreams/exampleUpstream/targets/www.baidu.com:80
curl -i -X GET --url http://127.0.0.1:8001/upstreams/exampleUpstream/targets
3. Service
curl -i -X POST --url http://127.0.0.1:8001/services --data 'name=example' --data 'url=http://www.baidu.com'
curl -i -X GET --url http://127.0.0.1:8001/services/example
curl -i -X PATCH --url http://127.0.0.1:8001/services/example --data 'retries=10' --data 'connect_timeout=80000'
curl -i -X DELETE --url http://127.0.0.1:8001/services/example
curl -i -X GET --url http://127.0.0.1:8001/services?size=10
4.Routes
curl -i -X POST --url http://127.0.0.1:8001/services/example/routes --data 'name=ft' --data 'hosts[]=baidu.com' --data 'paths[]=/first'
curl -i -X GET --url http://127.0.0.1:8001/services/example/routes/ft
curl -i -X PATCH --url http://127.0.0.1:8001/services/example/routes/ft --data 'request_buffering=false' --data "tags[]=tag1" --data "tags[]=tag2"
curl -i -X DELETE --url http://127.0.0.1:8001/services/example/routes/ft
curl -i -X GET --url http://127.0.0.1:8001/routes?size=10
5.Consumers
curl -i -X POST --url http://127.0.0.1:8001/consumers --data "username=jack"
curl -i -X GET --url http://127.0.0.1:8001/consumers/jack
curl -i -X PATCH --url http://127.0.0.1:8001/consumers/jack --data "tags[]=tag1" --data "tags[]=tag2"
curl -i -X DELETE --url http://127.0.0.1:8001/consumers/jack
curl -i -X GET --url http://127.0.0.1:8001/consumers?size=10
6. ACL
curl -i -X POST --url http://127.0.0.1:8001/services/example/plugins --data "name=acl" --data "config.allow=admin"
curl -i -X GET --url http://localhost:8000/first --header "Authorization: Basic amFjazoxMjM0NTY=" --header 'Host: baidu.com'
{
"message":"You cannot consume this service"
}
curl -i -X POST --url http://localhost:8001/consumers/jack/acls --data "group=admin"
curl -i -X GET --url http://localhost:8000/first --header "Authorization: Basic amFjazoxMjM0NTY=" --header 'Host: baidu.com'
百度一下,你就知道
......................
curl -i -X DELETE http://localhost:8001/services/example/plugins/1541e339-7b8f-4a1e-8485-45b0a28b55a8
7. Basic-Auth
curl -i -X POST --url http://localhost:8001/services/example/plugins --data "name=basic-auth"
curl -i -X POST --url http://localhost:8001/consumers/jack/basic-auth --data "username=jack" --data "password=123456"
curl -i -X GET --url http://localhost:8000/first --header 'Host:baidu.com'
{
"message":"Unauthorized"
}
curl -i -X GET --url http://localhost:8000/first --header "Authorization: Basic xxxxx=" --header 'Host: baidu.com'
{
"message":"Invalid authentication credentials"
}
curl -i -X GET --url http://localhost:8000/first --header "Authorization: Basic amFjazoxMjM0NTY=" --header 'Host: baidu.com'
百度一下,你就知道
......................
curl -i -X DELETE http://localhost:8001/services/example/plugins/3d9703d5-bafb-4374-931c-a03222e3aef6
8. Key-Auth
curl -X POST http://localhost:8001/services/example/plugins --data "name=key-auth" --data "config.key_names=apikey"
curl -i -X POST --url http://localhost:8001/consumers/jack/key-auth --data 'key=123'
curl http://localhost:8000/first --header 'Host:baidu.com'
{
"message":"No API key found in request"
}
curl http://localhost:8000/first?apikey=1231 --header 'Host:baidu.com'
{
"message":"Invalid authentication credentials"
}
curl http://localhost:8000/first?apikey=123 --header 'Host:baidu.com'
百度一下,你就知道
......................
curl -i -X DELETE http://localhost:8001/services/example/plugins/2ea0a367-e17e-4e8e-9b8f-8e8b9bf49681
9. IP-Restriction
curl -X POST http://localhost:8001/services/example/plugins --data "name=ip-restriction" --data "config.deny=118.123.78.69"
curl -i -X GET --url http://localhost:8000/first --header 'Host: baidu.com'
{
"message":"Your IP address is not allowed"
}
curl -i -X PATCH http://localhost:8001/services/example/plugins/08fe31e8-e961-4703-9d29-a877eed7c5c1 --data "config.deny=" --data "config.allow=118.123.78.69"
curl -i -X DELETE http://localhost:8001/services/example/plugins/08fe31e8-e961-4703-9d29-a877eed7c5c1
10. Rate-Limiting
curl -X POST http://localhost:8001/services/example/plugins --data "name=rate-limiting" --data "config.second=2" --data "config.policy=local"
curl -i -X GET --url http://localhost:8000/first --header 'Host: baidu.com'
{
"message":"API rate limit exceeded"
}
curl -i -X DELETE http://localhost:8001/services/example/plugins/9172ccc6-9734-4567-a442-04b03c5d7989
11. Request-Termination
curl -X POST http://localhost:8001/services/example/plugins --data "name=request-termination" --data "config.status_code=200" --data "config.message=Test !! "
curl -i -X GET --url http://localhost:8000/first --header 'Host: baidu.com'
{"message":"Test ll"}
curl -i -X DELETE http://localhost:8001/services/example/plugins/cbf087f5-aa50-418d-a8a2-325ebb6c9109