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);
|
route = AddQueryString(route, queryParams);
|
||||||
|
|
||||||
var res = await Http.GetAsync(route, cancel);
|
var res = await Http.GetAsync(route, cancel);
|
||||||
|
_logger?.LogCurl(Http, HttpMethod.Get, route);
|
||||||
|
|
||||||
return res.IsSuccessStatusCode
|
return res.IsSuccessStatusCode
|
||||||
? new()
|
? new()
|
||||||
@ -71,6 +72,8 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
|||||||
|
|
||||||
var res = await Http.GetAsync(route, cancel);
|
var res = await Http.GetAsync(route, cancel);
|
||||||
|
|
||||||
|
_logger?.LogCurl(Http, HttpMethod.Get, route);
|
||||||
|
|
||||||
return res.IsSuccessStatusCode
|
return res.IsSuccessStatusCode
|
||||||
? new()
|
? new()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,8 +7,8 @@ namespace Leanetec.EConnect.Infrastructure;
|
|||||||
|
|
||||||
public static class LogExtensions
|
public static class LogExtensions
|
||||||
{
|
{
|
||||||
public static void LogCurl<TCategoryName>(
|
public static void LogCurl(
|
||||||
this ILogger<TCategoryName> logger,
|
this ILogger logger,
|
||||||
HttpClient client,
|
HttpClient client,
|
||||||
HttpRequestMessage request,
|
HttpRequestMessage request,
|
||||||
Action<StringConfig>? config = null,
|
Action<StringConfig>? config = null,
|
||||||
@ -29,11 +29,11 @@ public static class LogExtensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogCurl<TCategoryName>(
|
public static void LogCurl(
|
||||||
this ILogger<TCategoryName> logger,
|
this ILogger logger,
|
||||||
HttpClient client,
|
HttpClient client,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
string uri = "/",
|
string? uri = null,
|
||||||
HttpRequestHeaders? headers = null,
|
HttpRequestHeaders? headers = null,
|
||||||
HttpContent? content = null,
|
HttpContent? content = null,
|
||||||
Action<StringConfig>? config = null,
|
Action<StringConfig>? config = null,
|
||||||
@ -44,7 +44,7 @@ public static class LogExtensions
|
|||||||
{
|
{
|
||||||
var curl = client.GenerateCurlInString(
|
var curl = client.GenerateCurlInString(
|
||||||
method,
|
method,
|
||||||
uri,
|
uri ?? "",
|
||||||
headers,
|
headers,
|
||||||
content,
|
content,
|
||||||
config
|
config
|
||||||
@ -57,8 +57,8 @@ public static class LogExtensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogCurl<TCategoryName>(
|
public static void LogCurl(
|
||||||
this ILogger<TCategoryName> logger,
|
this ILogger logger,
|
||||||
HttpClient client,
|
HttpClient client,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Uri uri,
|
Uri uri,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user