Dummy API Untuk HandsOn Kong API
- npm -i
- node index.js
Documentation from
docker network create kong-net
docker run -d --name kong-database --network=kong-net -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_DB=kong" -e "POSTGRES_PASSWORD=kong" postgres:9.6
docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_USER=kong" -e "KONG_PG_PASSWORD=kong" kong:latest kong migrations bootstrap
docker run -d --name kong --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_USER=kong" -e "KONG_PG_PASSWORD=kong" -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" -e "KONG_PROXY_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 kong:latest
POST localhost:8001
docker build -t dummy-api .
docker run -d -p 3000:3000 dummy-api
GET localhost:3000
POST localhost:8001/services
{
"name": "dummy-api",
"url": "http://10.163.205.115:3000"
}
GET localhost:8001/services
POST localhost:8001/services/dummy-api/routes
{
"name": "alternate",
"paths": ["/apidummy"]
}
GET localhost:8001/services/dummy-api/routes
GET localhost:8000/apidummy
POST localhost:8001/consumers
{
"username": "anon"
}
POST localhost:8001/consumers
{
"username": "betavianb"
}
POST localhost:8001/services/dummy-api/plugins
{
"name": "key-auth",
"config.key_names": "key"
}
POST localhost:8001/consumers/betavianb/key-auth
{
"consumer": { "id": "876bf719-8f18-4ce5-cc9f-5b5af6c36007" },
"created_at": 1443371053000,
"id": "62a7d3b7-b995-49f9-c9c8-bac4d781fb59",
"key": "62eb165c070a41d5c1b58d9d3d725ca1"
}
GET localhost:8000/apidummy
GET localhost:8000/apidummy
HEADER "key": "62eb165c070a41d5c1b58d9d3d725ca1"