Problem with routing rules

Hi,
2 routes have been declared for 1 service with method+path :

  1. method=POST,PATCH path=["/objects", “/objects/{id}”]
  2. method=DELETE path=["/objects/{id}"]
    DELETE request is not routed :
    Kong returns “no Route matched with those values”.
    Any idea ?
    Thx.

Hi,

I think you did not define your route correctly.

Please try below:

Create Service and Route

  1. Define first service
curl -X POST \
--url http://localhost:8001/services \
--header "Content-Type: application/json" \
--header "Accept: application/json, */*" \
--data '{"name":"first-service","url":"https://mockbin.org/request"}'
  1. Define first route. I assume ID numbers are in digits
curl -X POST \
--url http://localhost:8001/services/first-service/routes \
--header "Content-Type: application/json" \
--header "Accept: application/json, */*" \
--data '{"name":"first-route","paths":["/objects","/objects/(?<id>\\d+)"],"methods":["POST","PATCH"]}'
  1. Define second service (different upstream)
curl -X POST \
--url http://localhost:8001/services \
--header "Content-Type: application/json" \
--header "Accept: application/json, */*" \
--data '{"name":"second-service","url":"https://httpbin.org/anything"}'
  1. Define second route.
curl -X POST \
--url http://localhost:8001/services/second-service/routes \
--header "Content-Type: application/json" \
--header "Accept: application/json, */*" \
--data '{"name":"second-route","paths":["/objects/(?<id>\\d+)"],"methods":["DELETE"]}'

TEST

The DELETE request should reach httpbin

 curl -X DELETE http://localhost:8000/objects/123

The POST request should reach mockbin

curl -X POST http://localhost:8000/objects/123

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ