FreeKB - Kong get Routes using curl
Kong - get Routes using curl

The curl GET command can be used to determine if a service exists. This assumes you have already created a service. If not, refer to Kong - create service using cURL. Let's say you've created a service named "foo-service".


On the Kong server

If Kong is running on docker, refer to Kong - Docker container command line for the steps on how to issue commands in the Kong Docker container. Assuming you are using the default kong.conf file, the Kong Admin API will listen on port 8001.

If issuing this command on the Kong server, this command will display every route.

curl -X GET "http://localhost:8001/routes"

 

This will display every route with foo-service.

curl -X GET "http://localhost:8001/services/foo-service/routes"

 


From a remote server

If issuing this command from a remote server, this command will display every route.

curl -X GET "http://hostname:8000/admin-api/routes"

 

This will display every route with foo-service.

curl -X GET "http://hostname:8000/admin-api/services/foo-service/routes"

 


Validation

If there are no routes, something like this will be displayed.

{"next":null,"data":[]}

 

If there are routes, something like this will be displayed.

{
 "next":null,
 "data":[
          {
            "id":"a714d55e-a168-4efc-ae1a-6c380b0d5c84",
            "path_handling":"v0",
            "paths" => [
                         "/example/endpoint"
                       ],
            "destinations":null,
            "headers":null,
            "protocols":["http","https"],
            "methods":null,
            "snis":null,
            "service":{
                        "id":"fbb57bfd-124b-451c-841c-dbfea2b9ee8b"
                      },
            "name":null,
            "strip_path":true,
            "preserve_host":false,
            "regex_priority":0,
            "updated_at":1584417746,
            "sources":null,
            "hosts":[
                      "example.com"
                    ],
            "https_redirect_status_code":426,
            "tags":null,
            "created_at":1584417746
          }
        ]
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter bb7ca in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |