-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: enable eid logger feature flag (#13588)
- Loading branch information
1 parent
99d9790
commit e061605
Showing
4 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 14 additions & 2 deletions
16
backend/src/Designer/TypedHttpClients/EidLogger/EidLoggerClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
using System.Net.Http; | ||
using System.Net.Mime; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Altinn.Studio.Designer.TypedHttpClients.EidLogger; | ||
|
||
public class EidLoggerClient : IEidLoggerClient | ||
{ | ||
private readonly HttpClient _httpClient; | ||
private readonly JsonSerializerOptions _jsonSerializerOptions = new JsonSerializerOptions | ||
{ | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase | ||
}; | ||
|
||
public EidLoggerClient(HttpClient httpClient) | ||
{ | ||
_httpClient = httpClient; | ||
} | ||
|
||
public async Task Log(EidLogRequest request) | ||
public async Task Log(EidLogRequest request, CancellationToken cancellationToken = default) | ||
{ | ||
var response = await _httpClient.PostAsJsonAsync("eid-event-log", request); | ||
using var payloadContent = new StringContent(JsonSerializer.Serialize(request, _jsonSerializerOptions), | ||
Encoding.UTF8, | ||
MediaTypeNames.Application.Json); | ||
|
||
using var response = await _httpClient.PostAsync("eid-event-log", payloadContent, cancellationToken); | ||
response.EnsureSuccessStatusCode(); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
backend/src/Designer/TypedHttpClients/EidLogger/IEidLoggerClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Altinn.Studio.Designer.TypedHttpClients.EidLogger; | ||
|
||
public interface IEidLoggerClient | ||
{ | ||
public Task Log(EidLogRequest request); | ||
public Task Log(EidLogRequest request, CancellationToken cancellationToken = default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters