Skip to content

Commit

Permalink
feat: expose api client hooks for dotnet (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbward authored Jan 2, 2025
1 parent 1464c03 commit c446ce6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions contrib/dotnet/ApiClientHooks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using RestSharp;
using System;

namespace Ory.Client.Client
{
public partial class ApiClient : ISynchronousClient, IAsynchronousClient
{
/// <summary>
/// Hook to access the underlying RestRequest before the request is sent.
/// </summary>
public Action<RestRequest>? RequestHook { get; set; }

/// <summary>
/// Hook to access the underlying RestRequest and RestResponse after the response is received.
/// </summary>
public Action<RestRequest, RestResponse>? ResponseHook { get; set; }

partial void InterceptRequest(RestRequest request)
{
RequestHook?.Invoke(request);
}

partial void InterceptResponse(RestRequest request, RestResponse response)
{
ResponseHook?.Invoke(request, response);
}
}
}
1 change: 1 addition & 0 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ dotnet () {
--git-host github.com \
-c ./config/client/dotnet.yml.proc.yml
cp "LICENSE" "clients/${PROJECT}/dotnet"
cp "contrib/dotnet/ApiClientHooks.cs" "clients/${PROJECT}/dotnet/src/Ory.Client/Client"
}

dart () {
Expand Down

0 comments on commit c446ce6

Please sign in to comment.