Skip to content

Instantly share code, notes, and snippets.

@angelmmg90
Created September 21, 2017 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelmmg90/13d819641f4bd122d3f1db99632b7458 to your computer and use it in GitHub Desktop.
Save angelmmg90/13d819641f4bd122d3f1db99632b7458 to your computer and use it in GitHub Desktop.
KONG
kong start --> iniciamos kong
kong stop --> paramos kong
kong reload --> recargamos kong
curl -i -X POST \
--url http://localhost:8001/apis/ \
--data 'name=example-api' \
--data 'hosts=example.com' \
--data 'upstream_url=http://httpbin.org' --> Añadimos nuestra API con la upstream_url correspondiente
curl -i -X GET \
--url http://localhost:8000/ \
--header 'Host: example.com' --> Comprobamos que recibimos lo que la API nos da por get en la url del servidor creada anteriormente.
curl -i -X POST \
--url http://localhost:8001/apis/example-api/plugins/ \
--data 'name=key-auth' --> Habilitamos un plugin, indicando la url y el nombre correspondientes.
curl -i -X GET \
--url http://localhost:8000/ \
--header 'Host: example.com' --> Verificamos que el plugin está correctamente configurado haciendo un get al puerto cliente
curl -i -X POST \
--url http://localhost:8001/consumers/ \
--data "username=Jason" --> Añadimos un consumidor a la url correspondiente indicando el nombre.
--data "custom_id=<CUSTOM_ID>"
curl -i -X POST \
--url http://localhost:8001/consumers/Jason/key-auth/ \
--data 'key=ENTER_KEY_HERE' -> Introducimos la clave correspondiente al consumidor previamente creado en la url correspondiente
curl -i -X GET \
--url http://localhost:8000 \
--header "Host: example.com" \
--header "apikey: ENTER_KEY_HERE" --> Realizamos un get al puerto cliente indicando la clave del consumidor para poder conseguir los datos que nos devuelve la API a la cual apunta el Host indicado
$ curl -X POST http://localhost:8001/consumers/{consumer_or_id}/jwt -H "Content-Type: application/x-www-form-urlencoded" --> Creamos una credencialJWT
$ curl -X POST http://localhost:8001/consumers/{consumer_or_id}/jwt -H "Content-Type: application/x-www-form-urlencoded" --data "secret=<SECRET>" --> Creamos una credencial JWT con un secret en concreto
$ curl -X DELETE http://localhost:8001/consumers/{consumer}/jwt/{id_of_the_JWT_credential} --> Borramos una credencial JWT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment