Skip to content

Commit

Permalink
docs: readme tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Sep 5, 2024
1 parent 84059ba commit f7b23f1
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions packages/kong-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,72 @@ With [ReadMe's Metrics API](https://readme.com/metrics) your team can get deep i
- The plugin sends ReadMe the details of your API's incoming requests and outgoing responses, with the option for you to redact any private headers using the configuration options.
- ReadMe uses these request and response details to create an API Metrics Dashboard which can be used to analyze specific API calls or monitor aggregate usage data.

### Deploying locally
### 📦 Deploying locally

```bash
docker build -t kong-readme-plugin:1 .
curl -Ls https://get.konghq.com/quickstart | bash -s -- -r "" -i kong-readme-plugin -t 1
curl -i -s -X POST http://localhost:8001/plugins --data name=readme-plugin --data 'config.api_key=<Your API Key>'
# setup endpoints or test

# Setup endpoints or test
curl -i http://localhost:8000/mock/anything
```

### testing
### 🧑‍🔬 Testing

```bash
pongo up
pongo shell
kms
# check if the plugin is available

# Check if the plugin is available
curl -s localhost:8001 | jq '.plugins.available_on_server."readme-plugin"'
```

#### Enable for all services

```bash
curl -i -s -X POST http://localhost:8001/plugins --data name=readme-plugin --data 'config.api_key=<Your API Key>'
```

#### Enable for a specific service route

```bash
# add a new service
# Add a new service
curl -i -s -X POST http://localhost:8001/services --data name=example_service --data url='http://httpbin.org'
# Associate the custom plugin with the example_service service

# Associate the custom plugin with the `example_service` service
curl -is -X POST http://localhost:8001/services/example_service/plugins --data 'name=readme-plugin' -d "config.queue.max_retry_time=1"
# Add a new route for sending requests through the example_service

# Add a new route for sending requests through the `example_service` service
curl -i -X POST http://localhost:8001/services/example_service/routes --data 'paths[]=/mock' --data name=example_route
# test

# Test
curl -i http://localhost:8000/mock/anything
```

### Development tricks

Get plugin config for a route

```bash
curl -s http://localhost:8001/plugins | jq '.data | map(select(.name == "readme-plugin")) | first'
```

```bash
# get plugin id
# Retrieve the plugin ID
export PLUGIN_ID=$(curl -s http://localhost:8001/plugins | jq '.data | map(select(.name == "readme-plugin")) | first | .id' | tr -d '"')

# Configure the plugin with your API key
curl -sX PATCH http://localhost:8001/plugins/$PLUGIN_ID --data "config.api_key=<Your API Key>" | jq '.config.api_key'
# configure Hide headers

# Configure `hide_headers`
curl -sX PATCH -H'Content-Type: application/json' http://localhost:8001/plugins/$PLUGIN_ID --data '{"config": {"hide_headers": {"foo": "", "bar": "default"}}}' | jq '.config.hide_headers'
# configure id_header

# Configure `id_header`
curl -sX PATCH -H'Content-Type: application/json' http://localhost:8001/plugins/$PLUGIN_ID --data '{"config": {"id_header": "email"}}' | jq '.config.id_header'
```


> 🚧 Any Issues?
>
> Integrations can be tricky! [Contact support](https://docs.readme.com/guides/docs/contact-support) if you have any questions/issues.

0 comments on commit f7b23f1

Please sign in to comment.