diff --git a/app/_how-tos/create-a-custom-webhook-slack.md b/app/_how-tos/create-a-custom-webhook-slack.md index 4fb7fe05..7eedd31b 100644 --- a/app/_how-tos/create-a-custom-webhook-slack.md +++ b/app/_how-tos/create-a-custom-webhook-slack.md @@ -20,7 +20,8 @@ prereqs: inline: - title: A Slack webhook application include_content: prereqs/event-hook/slack - + - title: cURL + include_content: prereqs/tools/curl - title: Reload {{site.base_gateway}} include_content: prereqs/event-hook/restart-kong-gateway cleanup: @@ -31,10 +32,11 @@ cleanup: --- -Using the `webhook-custom` handler, you can configure an Event Hook that listens for events on a source. The `webhook-custom` handler offers a template that you can configure to create a custom webhook. In this tutorial, we will configure an Event Hook that issues a `POST` request when a `crud` event happens on the Consumer entity. That `POST` request will be made to a Slack webhook application containing a custom message describing the event. ## 1. Configure an Event Hook using the `webhook-custom` handler +Using the `webhook-custom` handler, you can configure an Event Hook that listens for events on a source. The `webhook-custom` handler offers a template that you can configure to create a custom webhook. In this tutorial, we will configure an Event Hook that issues a `POST` request when a `crud` event happens on the Consumer entity. That `POST` request will be made to a Slack webhook application containing a custom message describing the event. + curl -X POST http://localhost:8001/event-hooks \ -H "Content-Type: application/json" \ -d '{ @@ -63,10 +65,6 @@ Posting this will result in a `200` response. The `config` body in the Event Hoo ## 2. Validate the webhook -Validation happens in two steps: -1. Create a Consumer -2. Check Slack for a response containing your payload. - {:.warning} > **Important**: Before you can use Event Hooks for the first time, {{site.base_gateway}} needs to be [reloaded](/how-tos/restart-kong-gateway-container). diff --git a/app/_how-tos/create-a-lambda-event-hook.md b/app/_how-tos/create-a-lambda-event-hook.md index 878c1e42..453e1a67 100644 --- a/app/_how-tos/create-a-lambda-event-hook.md +++ b/app/_how-tos/create-a-lambda-event-hook.md @@ -22,6 +22,8 @@ prereqs: inline: - title: Reload {{site.base_gateway}} include_content: prereqs/event-hook/restart-kong-gateway + - title: cURL + include_content: prereqs/tools/curl cleanup: inline: - title: Destroy the {{site.base_gateway}} container @@ -29,11 +31,10 @@ cleanup: icon_url: /assets/icons/gateway.svg --- -A `lambda` Event Hook is an Event Hook that utilizes the `lambda` handler to pass custom code to an Event Hook. Depending on the source and individual event, that code can execute during various stages of the lifecycle of an event. In this guide, you will create an `lambda` Event Hook with custom code that logs an error with a specific message every time you create a Consumer. - - ## 1. Create a lambda Event Hook +A `lambda` Event Hook is an Event Hook that utilizes the `lambda` handler to pass custom code to an Event Hook. Depending on the source and individual event, that code can execute during various stages of the lifecycle of an event. In this guide, you will create an `lambda` Event Hook with custom code that logs an error with a specific message every time you create a Consumer. + Create a lua script to load into the lambda Event Hook. ```lua @@ -64,10 +65,6 @@ curl -i -X POST http://localhost:8001/event-hooks \ ## 2. Validate the webhook -Validation happens in two steps: -1. Create a Consumer -2. Checking the logs file for your event - {:.warning} > **Important**: Before you can use event hooks for the first time, {{site.base_gateway}} needs to be reloaded. diff --git a/app/_how-tos/create-a-log-event-hook.md b/app/_how-tos/create-a-log-event-hook.md index 145260c9..5d686fc1 100644 --- a/app/_how-tos/create-a-log-event-hook.md +++ b/app/_how-tos/create-a-log-event-hook.md @@ -22,6 +22,8 @@ prereqs: inline: - title: Reload {{site.base_gateway}} include_content: prereqs/event-hook/restart-kong-gateway + - title: cURL + include_content: prereqs/tools/curl cleanup: inline: - title: Destroy the {{site.base_gateway}} container @@ -31,10 +33,10 @@ cleanup: --- -`log` Event Hook configuration specifies an event and a source. In this guide you will create an Event Hook that listens for CRUD events on the Consumers entity. This Event Hook will create a log entry when a CRUD event occurs. - ## 1. Create the Event Hook +`log` Event Hook configuration specifies an event and a source. In this guide you will create an Event Hook that listens for CRUD events on the Consumers entity. This Event Hook will create a log entry when a CRUD event occurs. + Create a long Event Hook on the `consumers` event using the `crud` source: ```sh diff --git a/app/_how-tos/create-a-webhook-with-kong-gateway.md b/app/_how-tos/create-a-webhook-with-kong-gateway.md index 9a42310a..137b348f 100644 --- a/app/_how-tos/create-a-webhook-with-kong-gateway.md +++ b/app/_how-tos/create-a-webhook-with-kong-gateway.md @@ -22,7 +22,9 @@ prereqs: - title: A webhook URL content: | * You can generate a URL by navigating to https://webhook.site and copying the free URL. - * Set that URL as an environment variable `export WEBHOOK_URL=YOUR_URL` + * Set that URL as an environment variable `export WEBHOOK_URL=YOUR_URL`prereqs: + - title: cURL + include_content: prereqs/tools/curl - title: Reload {{site.base_gateway}} include_content: prereqs/event-hook/restart-kong-gateway cleanup: @@ -33,11 +35,10 @@ cleanup: --- -The `webhook` handler is used to configure webhooks that make a `POST` request to the URL provided during configuration. The Event Hook will push information to this URL with the event data. In this guide you will configure an Event Hook that will issue a `POST` request every time an event type `consumers` has a CRUD event. - - ## 1. Create a webhook +The `webhook` handler is used to configure webhooks that make a `POST` request to the URL provided during configuration. The Event Hook will push information to this URL with the event data. In this guide you will configure an Event Hook that will issue a `POST` request every time an event type `consumers` has a CRUD event. + Using the Admin API, create an Event Hook on the Consumers event by issuing a `POST` request to the `/event-hooks` endpoint. ```sh @@ -58,12 +59,7 @@ Issuing this `POST` request will send a request of type `ping` to the webhook UR -## Validate the webhook - -Validation happens in two steps: -1. Create a Consumer using the Admin API - -2. Check `webhook.site` for a `POST` request containing information about the event. +## 2. Validate the webhook {:.warning} > **Important**: Before you can use Event Hooks for the first time, {{site.base_gateway}} needs to be reloaded. diff --git a/app/_includes/prereqs/tools/curl.md b/app/_includes/prereqs/tools/curl.md new file mode 100644 index 00000000..0d1c8e83 --- /dev/null +++ b/app/_includes/prereqs/tools/curl.md @@ -0,0 +1,2 @@ +[cURL](https://curl.se/) is used to send requests to {{site.base_gateway}}. +`curl` is pre-installed on most systems. \ No newline at end of file