Skip to content

Commit

Permalink
Clarify that only json policy configuration is currently supported (n…
Browse files Browse the repository at this point in the history
…grok#826)

After spending too much time debugging my `yaml` config and then
learning we don't support it yet for the SKDs, I'm adding a note so no
one else repeats this.

---------

Co-authored-by: DevMandy <[email protected]>
  • Loading branch information
DevMandy and DevMandy authored Jul 9, 2024
1 parent b2cbdc3 commit d209aba
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 86 deletions.
86 changes: 43 additions & 43 deletions examples/javascript-sdk/http-traffic-policy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,50 @@ const fs = require("fs");
})();
```

```yaml title="policy.json"
:::info

Traffic Policies can be defined in `json` only when using the SDKs.
Support for `yaml` is coming soon!

:::

```json title="policy.json"
{
"inbound":
[
{
"name": "FooBarParamNotFound",
"expressions": ["'bar' in getQueryParam('foo')"],
"actions":
[
{
"type": "custom-response",
"config":
{
"status_code": 404,
"content": "not found",
"headers": { "content-type": "text/plain" },
},
},
],
},
{
"name": "BazCookieForLargeRequests",
"expressions": ["!hasReqCookie('baz')", "req.content_length > 5000"],
"actions": [{ "type": "deny" }],
},
],
"outbound":
[
{
"name": "LogUnsuccessfulRequests",
"expressions": ["res.status_code < 200 && res.status_code >= 300"],
"actions":
[
{
"type": "log",
"config":
{
"metadata":
{ "hostport": "example.com:443", "success": false },
},
},
],
},
],
"inbound": [
{
"name": "FooBarParamNotFound",
"expressions": ["'bar' in getQueryParam('foo')"],
"actions": [
{
"type": "custom-response",
"config": {
"status_code": 404,
"content": "not found",
"headers": { "content-type": "text/plain" }
}
}
]
},
{
"name": "BazCookieForLargeRequests",
"expressions": ["!hasReqCookie('baz')", "req.content_length > 5000"],
"actions": [{ "type": "deny" }]
}
],
"outbound": [
{
"name": "LogUnsuccessfulRequests",
"expressions": ["res.status_code < 200 && res.status_code >= 300"],
"actions": [
{
"type": "log",
"config": {
"metadata": { "hostport": "example.com:443", "success": false }
}
}
]
}
]
}
```

Expand Down
86 changes: 43 additions & 43 deletions examples/python-sdk/http-traffic-policy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,50 @@ with open('/path/to/policy.json') as f:
listener = await session.http_endpoint().policy(policy).listen()
```

```yaml title="policy.json"
:::info

Traffic Policies can be defined in `json` only when using the SDKs.
Support for `yaml` is coming soon!

:::

```json title="policy.json"
{
"inbound":
[
{
"name": "FooBarParamNotFound",
"expressions": ["'bar' in getQueryParam('foo')"],
"actions":
[
{
"type": "custom-response",
"config":
{
"status_code": 404,
"content": "not found",
"headers": { "content-type": "text/plain" },
},
},
],
},
{
"name": "BazCookieForLargeRequests",
"expressions": ["!hasReqCookie('baz')", "req.content_length > 5000"],
"actions": [{ "type": "deny" }],
},
],
"outbound":
[
{
"name": "LogUnsuccessfulRequests",
"expressions": ["res.status_code < 200 && res.status_code >= 300"],
"actions":
[
{
"type": "log",
"config":
{
"metadata":
{ "hostport": "example.com:443", "success": false },
},
},
],
},
],
"inbound": [
{
"name": "FooBarParamNotFound",
"expressions": ["'bar' in getQueryParam('foo')"],
"actions": [
{
"type": "custom-response",
"config": {
"status_code": 404,
"content": "not found",
"headers": { "content-type": "text/plain" }
}
}
]
},
{
"name": "BazCookieForLargeRequests",
"expressions": ["!hasReqCookie('baz')", "req.content_length > 5000"],
"actions": [{ "type": "deny" }]
}
],
"outbound": [
{
"name": "LogUnsuccessfulRequests",
"expressions": ["res.status_code < 200 && res.status_code >= 300"],
"actions": [
{
"type": "log",
"config": {
"metadata": { "hostport": "example.com:443", "success": false }
}
}
]
}
]
}
```

Expand Down

0 comments on commit d209aba

Please sign in to comment.