Skip to content

Commit b5fd4bb

Browse files
committed
client build v1.2.3
1 parent f39afb2 commit b5fd4bb

6 files changed

Lines changed: 50 additions & 3 deletions

File tree

NpgsqlRest.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1414
annotations.md = annotations.md
1515
.github\workflows\build-test-publish.yml = .github\workflows\build-test-publish.yml
1616
changelog.md = changelog.md
17+
client.md = client.md
1718
LICENSE = LICENSE
1819
options.md = options.md
1920
README.md = README.md

NpgsqlRestClient/Builder.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.Authentication.BearerToken;
1+
using System.Data.Common;
2+
using Microsoft.AspNetCore.Authentication.BearerToken;
23
using Microsoft.AspNetCore.Authentication.Cookies;
34
using Microsoft.Extensions.Primitives;
45
using Microsoft.Net.Http.Headers;
@@ -268,13 +269,30 @@ public static void BuildCors()
268269
return connectionString;
269270
}
270271

272+
private static string? _instanceId = null;
273+
274+
public static string InstanceId
275+
{
276+
get
277+
{
278+
_instanceId ??= Convert.ToBase64String(Guid.NewGuid().ToByteArray());
279+
return _instanceId;
280+
}
281+
}
282+
271283
public static Dictionary<string, StringValues> GetCustomHeaders()
272284
{
273285
var result = new Dictionary<string, StringValues>();
274286
foreach(var section in NpgsqlRestCfg.GetSection("CustomRequestHeaders").GetChildren())
275287
{
276288
result.Add(section.Key, section.Value);
277289
}
290+
291+
var instIdName = GetConfigStr("InstanceIdRequestHeaderName", NpgsqlRestCfg);
292+
if (string.IsNullOrEmpty(instIdName) is false)
293+
{
294+
result.Add(instIdName, InstanceId);
295+
}
278296
return result;
279297
}
280298
}

NpgsqlRestClient/NpgsqlRestClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<InvariantGlobalization>true</InvariantGlobalization>
88
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
99
<PublishAot>true</PublishAot>
10-
<Version>1.2.2</Version>
10+
<Version>1.2.3</Version>
1111
</PropertyGroup>
1212

1313
<ItemGroup>

NpgsqlRestClient/appsettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@
371371
"57014": 205
372372
},
373373
//
374+
// Add the unique NpgsqlRest instance id request header with this name to the response or set to null to ignore.
375+
//
376+
"InstanceIdRequestHeaderName": null,
377+
//
374378
// https://vb-consulting.github.io/npgsqlrest/options/#customrequestheaders
375379
//
376380
"CustomRequestHeaders": {

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NpgsqlRest
22

3-
![build-test-publish](https://github.com/vb-consulting/NpgsqlRest/workflows/build-test-publish/badge.svg)
3+
[![build-test-publish](https://github.com/vb-consulting/NpgsqlRest/actions/workflows/build-test-publish.yml/badge.svg)](https://github.com/vb-consulting/NpgsqlRest/actions/workflows/build-test-publish.yml)
44
![License](https://img.shields.io/badge/license-MIT-green)
55
![GitHub Stars](https://img.shields.io/github/stars/vb-consulting/NpgsqlRest?style=social)
66
![GitHub Forks](https://img.shields.io/github/forks/vb-consulting/NpgsqlRest?style=social)

client.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,30 @@ Example: npgsqlrest appsettings.json -o appsetting
7878

7979
## Changelog
8080

81+
### Version 1.2.3
82+
83+
New setting `NpgsqlRest.InstanceIdRequestHeaderName`:
84+
85+
```jsonc
86+
{
87+
//
88+
//...
89+
//
90+
"NpgsqlRest": {
91+
"InstanceIdRequestHeaderName": "X-Instance-Id"
92+
}
93+
//
94+
//...
95+
//
96+
}
97+
```
98+
99+
The `NpgsqlRest.InstanceIdRequestHeaderName` setting allows you to specify the header name that will be used to identify the instance of the application. Header value will be used as the unique running instance ID.
100+
101+
This is useful when you have multiple instances of the application running behind a load balancer, and you want to identify which instance is handling the request.
102+
103+
Default is `null` (not used).
104+
81105
### Version 1.2.2
82106

83107
New setting `NpgsqlRest.AuthenticationOptions.CustomParameterNameToClaimMappings`:

0 commit comments

Comments
 (0)