feat: kick logs
This commit is contained in:
parent
6cb515c67d
commit
f524afb05b
7 changed files with 118 additions and 83 deletions
|
|
@ -15,6 +15,15 @@ public class PluralkitApiService(ILogger logger)
|
|||
private const string ApiBaseUrl = "https://api.pluralkit.me/v2";
|
||||
private readonly HttpClient _client = new();
|
||||
private readonly ILogger _logger = logger.ForContext<PluralkitApiService>();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||
}.ConfigureForNodaTime(
|
||||
new NodaJsonSettings
|
||||
{
|
||||
InstantConverter = new NodaPatternConverter<Instant>(InstantPattern.ExtendedIso),
|
||||
}
|
||||
);
|
||||
|
||||
private readonly ResiliencePipeline _pipeline = new ResiliencePipelineBuilder()
|
||||
.AddRateLimiter(
|
||||
|
|
@ -59,17 +68,7 @@ public class PluralkitApiService(ILogger logger)
|
|||
throw new CataloggerError("Non-200 status code from PluralKit API");
|
||||
}
|
||||
|
||||
var jsonOptions = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||
}.ConfigureForNodaTime(
|
||||
new NodaJsonSettings
|
||||
{
|
||||
InstantConverter = new NodaPatternConverter<Instant>(InstantPattern.ExtendedIso),
|
||||
}
|
||||
);
|
||||
|
||||
return await resp.Content.ReadFromJsonAsync<T>(jsonOptions, ct)
|
||||
return await resp.Content.ReadFromJsonAsync<T>(_jsonOptions, ct)
|
||||
?? throw new CataloggerError("JSON response from PluralKit API was null");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue