Skip to content

Commit

Permalink
More proxy docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Jan 8, 2024
1 parent fed02b0 commit 4d14788
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
32 changes: 19 additions & 13 deletions website/docs/advanced/proxy/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ CONFIGCAT_HTTP_CDN_PROXY_CORS_ALLOWED_ORIGINS_REGEX_PATTERNS='["https:\\/\\/.*do
<td>-</td>
<td>List of regex patterns used to match allowed CORS origins. When it's set, the Proxy will match the request's <code>Origin</code> with the given regex patterns. When there's a match, the <code>Access-Control-Allow-Origin</code> response header will be set to the matched origin.<br/>
When there's no matching request origin, the Proxy will set the <code>Access-Control-Allow-Origin</code> response header to the <code>if_no_match</code> field's value.
<br/>The <code>if_no_match</code> option is mandatory if this option is used.
<br/>The <code>if_no_match</code> option is mandatory if this option is used.<br/>When using the environment variable, the regex escape character must be doubled (<code>\\</code>) because it's parsed as a JSON list and <code>\</code> is also a JSON escape character.
</td>
</tr>

Expand Down Expand Up @@ -399,13 +399,15 @@ This endpoint evaluates a single feature flag identified by a `key` with the giv
"key": "<feature-flag-key>",
"user": {
"Identifier": "<user-id>",
"Email": "<user-email>",
"Country": "<user-country>",
"Rating": 4.5,
"Roles": ["Role1","Role2"],
// any other attribute
}
}
```

The type of the `user` object's fields can only be `string`, `number`, or `string[]`.

**Responses**:
<ul className="responses">
<li className="success"><span className="status">200</span>: The feature flag evaluation finished successfully.<br/>
Expand Down Expand Up @@ -437,15 +439,18 @@ This endpoint evaluates all feature flags with the given [user object](/advanced
**Request body**:
```json
{
"key": "<feature-flag-key>",
"user": {
"Identifier": "<user-id>",
"Email": "<user-email>",
"Country": "<user-country>",
"Rating": 4.5,
"Roles": ["Role1","Role2"],
// any other attribute
}
}
```

The type of the `user` object's fields can only be `string`, `number`, or `string[]`.

**Responses**:
<ul className="responses">
<li className="success"><span className="status">200</span>: The evaluation of all feature flags finished successfully.<br/>
Expand Down Expand Up @@ -643,7 +648,7 @@ CONFIGCAT_HTTP_API_CORS_ALLOWED_ORIGINS_REGEX_PATTERNS='["https:\\/\\/.*domain1\
<td>-</td>
<td>List of regex patterns used to match allowed CORS origins. When it's set, the Proxy will match the request's <code>Origin</code> with the given regex patterns. When there's a match, the <code>Access-Control-Allow-Origin</code> response header will be set to the matched origin.<br/>
When there's no matching request origin, the Proxy will set the <code>Access-Control-Allow-Origin</code> response header to the <code>if_no_match</code> field's value.
<br/>The <code>if_no_match</code> option is mandatory if this option is used.
<br/>The <code>if_no_match</code> option is mandatory if this option is used.<br/>When using the environment variable, the regex escape character must be doubled (<code>\\</code>) because it's parsed as a JSON list and <code>\</code> is also a JSON escape character.
</td>
</tr>

Expand Down Expand Up @@ -769,10 +774,10 @@ This endpoint subscribes to a single flag's changes. Whenever the watched flag's
```js title="example.js"
const rawData = {
key: "<feature-flag-key>",
user: {
user: { // field types can only be `string`, `number`, or `string[]`.
Identifier: "<user-id>",
Email: "<user-email>",
Country: "<user-country>",
Rating: 4.5,
Roles: ["Role1","Role2"],
// any other attribute
}
}
Expand Down Expand Up @@ -821,10 +826,10 @@ This endpoint subscribes to all feature flags' changes behind the given [SDK ide
**Example**:
```js title="example.js"
const rawData = {
user: {
user: { // field types can only be `string`, `number`, or `string[]`.
Identifier: "<user-id>",
Email: "<user-email>",
Country: "<user-country>",
Rating: 4.5,
Roles: ["Role1","Role2"],
// any other attribute
}
}
Expand Down Expand Up @@ -960,7 +965,8 @@ CONFIGCAT_HTTP_SSE_CORS_ALLOWED_ORIGINS_REGEX_PATTERNS='["https:\\/\\/.*domain1\
</td>
<td>-</td>
<td>List of regex patterns used to match allowed CORS origins. When it's set, the Proxy will match the request's <code>Origin</code> with the given regex patterns. When there's a match, the <code>Access-Control-Allow-Origin</code> response header will be set to the matched origin.<br/>
When there's no matching request origin, the Proxy will set the <code>Access-Control-Allow-Origin</code> response header to the <code>if_no_match</code> field's value.<br/>The <code>if_no_match</code> option is mandatory if this option is used.</td>
When there's no matching request origin, the Proxy will set the <code>Access-Control-Allow-Origin</code> response header to the <code>if_no_match</code> field's value.<br/>The <code>if_no_match</code> option is mandatory if this option is used.<br/>When using the environment variable, the regex escape character must be doubled (<code>\\</code>) because it's parsed as a JSON list and <code>\</code> is also a JSON escape character.
</td>
</tr>

<tr>
Expand Down
22 changes: 20 additions & 2 deletions website/docs/advanced/proxy/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ To establish gRPC connections, you'll need the protobuf and the gRPC <a target="
```protobuf title="flag_service.proto"
syntax = "proto3";
option go_package = "github.com/configcat/configcat-proxy/grpc/proto";
package configcat;
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
// Service that contains feature flag evaluation procedures.
service FlagService {
Expand All @@ -44,7 +47,7 @@ message EvalRequest {
// The feature flag's key to evaluate.
string key = 2;
// The user object.
map<string, string> user = 3;
map<string, UserValue> user = 3;
}
// Feature flag evaluation response message.
Expand Down Expand Up @@ -83,6 +86,21 @@ message RefreshRequest {
// The SDK identifier.
string sdk_id = 1;
}
// Defines the possible values that can be set in the `user` map.
message UserValue {
oneof value {
double number_value = 1;
string string_value = 2;
google.protobuf.Timestamp time_value = 3;
StringList string_list_value = 4;
}
}
// Represents a list of strings.
message StringList {
repeated string values = 1;
}
```

In order to secure the gRPC communication with the Proxy, set up [TLS](/advanced/proxy/proxy-overview#tls).
Expand Down Expand Up @@ -119,7 +137,7 @@ defer cancel()
resp, err := client.EvalFlag(ctx, &proto.EvalRequest{
SdkId: "my_sdk",
Key: "<flag-key>",
User: map[string]string{"Identifier": "<user-id>"}
User: map[string]*proto.UserValue{"Identifier": {Value: &proto.UserValue_StringValue{StringValue: "<user-id>"}}}
})
if err != nil {
panic(err)
Expand Down

0 comments on commit 4d14788

Please sign in to comment.