Skip to content

Commit

Permalink
docs: add envoy lib examples (#201)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly authored Nov 7, 2024
1 parent 63b2ddb commit aa48962
Showing 1 changed file with 86 additions and 17 deletions.
103 changes: 86 additions & 17 deletions website/docs/cel-extensions/envoy.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ envoy.Allowed() -> <OkHttpResponse>

#### Example

TODO
```
envoy.Allowed()
```

### envoy.Denied

Expand All @@ -42,7 +44,9 @@ envoy.Denied(<int> code) -> <DeniedHttpResponse>

#### Example

TODO
```
envoy.Denied(401)
```

### envoy.Response

Expand All @@ -62,7 +66,19 @@ envoy.Response(<DeniedHttpResponse> denied) -> <CheckResponse>

#### Example

TODO
```
// ok
envoy.Response(0)
// permission denied
envoy.Response(7)
```
```
envoy.Response(envoy.Allowed())
```
```
envoy.Response(envoy.Denied(401))
```

### envoy.Null

Expand All @@ -76,7 +92,9 @@ envoy.Null() -> <CheckResponse>

#### Example

TODO
```
envoy.Null()
```

### envoy.Header

Expand All @@ -90,7 +108,9 @@ envoy.Header(<string> key, <string> value) -> <HeaderValueOption>

#### Example

TODO
```
envoy.Header("foo", "bar")
```

### WithBody

Expand All @@ -104,12 +124,16 @@ This function sets the body of a `<DeniedHttpResponse>` object.

#### Example

TODO
```
envoy.Denied(401).WithBody("Unauthorized Request")
```

### WithHeader

This function adds a `<HeaderValueOption>` when the request is sent upstream by Envoy, in the case of an `OkHttpResponse`.
This function adds a `<HeaderValueOption>` when the response is sent downstream by Envoy, in the case of a `DeniedHttpResponse`.
This function adds a `<HeaderValueOption>`:

- When the request is sent upstream by Envoy, in the case of an `<OkHttpResponse>`.
- When the response is sent downstream by Envoy, in the case of a `<DeniedHttpResponse>`.

#### Signature and overloads

Expand All @@ -128,7 +152,18 @@ This function adds a `<HeaderValueOption>` when the response is sent downstream

#### Example

TODO
```
envoy.Allowed().WithHeader(envoy.Header("foo", "bar"))
```
```
envoy.Allowed().WithHeader("foo", "bar")
```
```
envoy.Denied(401).WithHeader(envoy.Header("foo", "bar"))
```
```
envoy.Denied(401).WithHeader("foo", "bar")
```

### WithoutHeader

Expand All @@ -142,7 +177,9 @@ This function marks a header to be removed when the request is sent upstream by

#### Example

TODO
```
envoy.Allowed().WithoutHeader("foo")
```

### WithResponseHeader

Expand All @@ -159,7 +196,12 @@ This function adds a `<HeaderValueOption>` when the response is sent downstream

#### Example

TODO
```
envoy.Allowed().WithResponseHeader(envoy.Header("foo", "bar"))
```
```
envoy.Allowed().WithResponseHeader("foo", "bar")
```

### WithQueryParam

Expand All @@ -173,7 +215,12 @@ This function adds a `<QueryParameter>` to be added when the request is sent ups

#### Example

TODO
```
envoy.Allowed().WithQueryParam(envoy.config.core.v3.QueryParameter{
key: "foo",
bar: "bar"
})
```

### WithoutQueryParam

Expand All @@ -187,7 +234,9 @@ This function marks a query parameter to be removed when the request is sent ups

#### Example

TODO
```
envoy.Allowed().WithoutQueryParam("foo")
```

### KeepEmptyValue

Expand All @@ -204,7 +253,12 @@ This function sets the `keep_empty_value` field of an `<HeaderValueOption>` obje

#### Example

TODO
```
envoy.Header("foo", "bar").KeepEmptyValue()
```
```
envoy.Header("foo", "bar").KeepEmptyValue(true)
```

### Response

Expand All @@ -221,7 +275,12 @@ This function creates a `<CheckResponse>` object from an `<OkHttpResponse>` or `

#### Example

TODO
```
envoy.Allowed().Response()
```
```
envoy.Denied(401).Response()
```

### WithMessage

Expand All @@ -235,7 +294,12 @@ This function sets the `status.message` field of a `<CheckResponse>` object.

#### Example

TODO
```
envoy.Allowed().Response().WithMessage("hello world!")
```
```
envoy.Denied(401).Response().WithMessage("hello world!")
```

### WithMetadata

Expand All @@ -249,4 +313,9 @@ This function sets the `dynamic_metadata` field of a `<CheckResponse>` object.

#### Example

TODO
```
envoy.Allowed().Response().WithMetadata({ "foo": "bar" })
```
```
envoy.Denied(401).Response().WithMetadata({ "foo": "bar" })
```

0 comments on commit aa48962

Please sign in to comment.