feat(EConnectClient): Curl-Logging für GET-Requests hinzugefügt
- Curl-Log wird jetzt auch bei `GetAsync` und `GetListAsAsyncEnumerable` ausgeführt. - Bisher wurde Logging nur bei `PostAsync` durchgeführt. - Hilft beim Debuggen von HTTP-Requests und beim Nachvollziehen von API-Aufrufen.
This commit is contained in:
parent
8b9f7b911d
commit
df089af385
@ -44,6 +44,7 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
||||
route = AddQueryString(route, queryParams);
|
||||
|
||||
var res = await Http.GetAsync(route, cancel);
|
||||
_logger?.LogCurl(Http, HttpMethod.Get, route);
|
||||
|
||||
return res.IsSuccessStatusCode
|
||||
? new()
|
||||
@ -71,6 +72,8 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
||||
|
||||
var res = await Http.GetAsync(route, cancel);
|
||||
|
||||
_logger?.LogCurl(Http, HttpMethod.Get, route);
|
||||
|
||||
return res.IsSuccessStatusCode
|
||||
? new()
|
||||
{
|
||||
|
||||
@ -7,8 +7,8 @@ namespace Leanetec.EConnect.Infrastructure;
|
||||
|
||||
public static class LogExtensions
|
||||
{
|
||||
public static void LogCurl<TCategoryName>(
|
||||
this ILogger<TCategoryName> logger,
|
||||
public static void LogCurl(
|
||||
this ILogger logger,
|
||||
HttpClient client,
|
||||
HttpRequestMessage request,
|
||||
Action<StringConfig>? config = null,
|
||||
@ -29,11 +29,11 @@ public static class LogExtensions
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogCurl<TCategoryName>(
|
||||
this ILogger<TCategoryName> logger,
|
||||
public static void LogCurl(
|
||||
this ILogger logger,
|
||||
HttpClient client,
|
||||
HttpMethod method,
|
||||
string uri = "/",
|
||||
string? uri = null,
|
||||
HttpRequestHeaders? headers = null,
|
||||
HttpContent? content = null,
|
||||
Action<StringConfig>? config = null,
|
||||
@ -44,7 +44,7 @@ public static class LogExtensions
|
||||
{
|
||||
var curl = client.GenerateCurlInString(
|
||||
method,
|
||||
uri,
|
||||
uri ?? "",
|
||||
headers,
|
||||
content,
|
||||
config
|
||||
@ -57,8 +57,8 @@ public static class LogExtensions
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogCurl<TCategoryName>(
|
||||
this ILogger<TCategoryName> logger,
|
||||
public static void LogCurl(
|
||||
this ILogger logger,
|
||||
HttpClient client,
|
||||
HttpMethod method,
|
||||
Uri uri,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user