Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose api client hooks for dotnet #389

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading