Skip to content

Commit 825a50d

Browse files
authored
Merge pull request #139 from weaviate/fix/headers-missing-in-grpc
Add support for custom headers in WeaviateGrpcClient
2 parents 4b157f9 + b893efa commit 825a50d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Weaviate.Client/WeaviateClient.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ public WeaviateClient(
229229
}
230230

231231
RestClient = new WeaviateRestClient(Configuration.RestUri, httpClient);
232-
GrpcClient = new WeaviateGrpcClient(Configuration.GrpcUri, wcdHost, _tokenService);
232+
GrpcClient = new WeaviateGrpcClient(
233+
Configuration.GrpcUri,
234+
wcdHost,
235+
_tokenService,
236+
Configuration.Headers
237+
);
233238

234239
Nodes = new NodesClient(RestClient);
235240
Collections = new CollectionsClient(this);

src/Weaviate.Client/gRPC/Client.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public WeaviateGrpcClient(
3838
Uri grpcUri,
3939
string? wcdHost,
4040
ITokenService? tokenService,
41+
Dictionary<string, string>? headers = null,
4142
ILogger<WeaviateGrpcClient>? logger = null
4243
)
4344
{
@@ -112,6 +113,19 @@ public WeaviateGrpcClient(
112113
{
113114
_defaultHeaders = new Metadata { { "X-Weaviate-Cluster-URL", wcdHost } };
114115
}
116+
if (headers != null)
117+
{
118+
if (_defaultHeaders == null)
119+
{
120+
_defaultHeaders = new Metadata();
121+
}
122+
123+
foreach (var header in headers)
124+
{
125+
_defaultHeaders.Add(header.Key, header.Value);
126+
}
127+
}
128+
115129
_grpcClient = new V1.Weaviate.WeaviateClient(_channel);
116130
}
117131

0 commit comments

Comments
 (0)