Skip to content

Commit c446ce6

Browse files
authored
feat: expose api client hooks for dotnet (#389)
1 parent 1464c03 commit c446ce6

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

contrib/dotnet/ApiClientHooks.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using RestSharp;
2+
using System;
3+
4+
namespace Ory.Client.Client
5+
{
6+
public partial class ApiClient : ISynchronousClient, IAsynchronousClient
7+
{
8+
/// <summary>
9+
/// Hook to access the underlying RestRequest before the request is sent.
10+
/// </summary>
11+
public Action<RestRequest>? RequestHook { get; set; }
12+
13+
/// <summary>
14+
/// Hook to access the underlying RestRequest and RestResponse after the response is received.
15+
/// </summary>
16+
public Action<RestRequest, RestResponse>? ResponseHook { get; set; }
17+
18+
partial void InterceptRequest(RestRequest request)
19+
{
20+
RequestHook?.Invoke(request);
21+
}
22+
23+
partial void InterceptResponse(RestRequest request, RestResponse response)
24+
{
25+
ResponseHook?.Invoke(request, response);
26+
}
27+
}
28+
}

scripts/generate.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ dotnet () {
227227
--git-host github.com \
228228
-c ./config/client/dotnet.yml.proc.yml
229229
cp "LICENSE" "clients/${PROJECT}/dotnet"
230+
cp "contrib/dotnet/ApiClientHooks.cs" "clients/${PROJECT}/dotnet/src/Ory.Client/Client"
230231
}
231232

232233
dart () {

0 commit comments

Comments
 (0)