Skip to content

Commit

Permalink
fix-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Guaris committed Dec 19, 2024
1 parent d83d368 commit f893565
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
10 changes: 4 additions & 6 deletions app/_how-tos/create-a-custom-webhook-slack.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 '{
Expand Down Expand Up @@ -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).
Expand Down
11 changes: 4 additions & 7 deletions app/_how-tos/create-a-lambda-event-hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ 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
include_content: cleanup/products/gateway
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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions app/_how-tos/create-a-log-event-hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 6 additions & 10 deletions app/_how-tos/create-a-webhook-with-kong-gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ prereqs:
- title: A webhook URL
content: |

Check failure on line 23 in app/_how-tos/create-a-webhook-with-kong-gateway.md

View workflow job for this annotation

GitHub Actions / Vale

[vale] reported by reviewdog 🐶 [docs.Spelling] Did you really mean 'prereqs'? Raw Output: {"message": "[docs.Spelling] Did you really mean 'prereqs'?", "location": {"path": "app/_how-tos/create-a-webhook-with-kong-gateway.md", "range": {"start": {"line": 23, "column": 80}}}, "severity": "ERROR"}
* 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:
Expand All @@ -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
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions app/_includes/prereqs/tools/curl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[cURL](https://curl.se/) is used to send requests to {{site.base_gateway}}.
`curl` is pre-installed on most systems.

0 comments on commit f893565

Please sign in to comment.