Skip to content

Commit

Permalink
client build v1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
vbilopav committed May 30, 2024
1 parent f39afb2 commit b5fd4bb
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 3 deletions.
1 change: 1 addition & 0 deletions NpgsqlRest.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
annotations.md = annotations.md
.github\workflows\build-test-publish.yml = .github\workflows\build-test-publish.yml
changelog.md = changelog.md
client.md = client.md
LICENSE = LICENSE
options.md = options.md
README.md = README.md
Expand Down
20 changes: 19 additions & 1 deletion NpgsqlRestClient/Builder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authentication.BearerToken;
using System.Data.Common;
using Microsoft.AspNetCore.Authentication.BearerToken;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
Expand Down Expand Up @@ -268,13 +269,30 @@ public static void BuildCors()
return connectionString;
}

private static string? _instanceId = null;

public static string InstanceId
{
get
{
_instanceId ??= Convert.ToBase64String(Guid.NewGuid().ToByteArray());
return _instanceId;
}
}

public static Dictionary<string, StringValues> GetCustomHeaders()
{
var result = new Dictionary<string, StringValues>();
foreach(var section in NpgsqlRestCfg.GetSection("CustomRequestHeaders").GetChildren())
{
result.Add(section.Key, section.Value);
}

var instIdName = GetConfigStr("InstanceIdRequestHeaderName", NpgsqlRestCfg);
if (string.IsNullOrEmpty(instIdName) is false)
{
result.Add(instIdName, InstanceId);
}
return result;
}
}
2 changes: 1 addition & 1 deletion NpgsqlRestClient/NpgsqlRestClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<InvariantGlobalization>true</InvariantGlobalization>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<PublishAot>true</PublishAot>
<Version>1.2.2</Version>
<Version>1.2.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions NpgsqlRestClient/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@
"57014": 205
},
//
// Add the unique NpgsqlRest instance id request header with this name to the response or set to null to ignore.
//
"InstanceIdRequestHeaderName": null,
//
// https://vb-consulting.github.io/npgsqlrest/options/#customrequestheaders
//
"CustomRequestHeaders": {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NpgsqlRest

![build-test-publish](https://github.com/vb-consulting/NpgsqlRest/workflows/build-test-publish/badge.svg)
[![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)
![License](https://img.shields.io/badge/license-MIT-green)
![GitHub Stars](https://img.shields.io/github/stars/vb-consulting/NpgsqlRest?style=social)
![GitHub Forks](https://img.shields.io/github/forks/vb-consulting/NpgsqlRest?style=social)
Expand Down
24 changes: 24 additions & 0 deletions client.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,30 @@ Example: npgsqlrest appsettings.json -o appsetting

## Changelog

### Version 1.2.3

New setting `NpgsqlRest.InstanceIdRequestHeaderName`:

```jsonc
{
//
//...
//
"NpgsqlRest": {
"InstanceIdRequestHeaderName": "X-Instance-Id"
}
//
//...
//
}
```

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.

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.

Default is `null` (not used).

### Version 1.2.2

New setting `NpgsqlRest.AuthenticationOptions.CustomParameterNameToClaimMappings`:
Expand Down

0 comments on commit b5fd4bb

Please sign in to comment.