|
| 1 | +# Dev Proxy Abstractions |
| 2 | + |
| 3 | +[](https://www.nuget.org/packages/DevProxy.Abstractions) |
| 4 | +[](https://www.nuget.org/packages/DevProxy.Abstractions) |
| 5 | + |
| 6 | +Abstractions for building custom [Dev Proxy](https://aka.ms/devproxy) plugins. Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path. |
| 7 | + |
| 8 | +## What This Package Does |
| 9 | + |
| 10 | +This package provides the interfaces, base classes, and models needed to build custom Dev Proxy plugins. Use it when you want to extend Dev Proxy with your own functionality. |
| 11 | + |
| 12 | +## Usage |
| 13 | + |
| 14 | +Create a new class library project and add a reference to this package: |
| 15 | + |
| 16 | +```bash |
| 17 | +dotnet add package DevProxy.Abstractions |
| 18 | +``` |
| 19 | + |
| 20 | +Then, implement the `IPlugin` interface or inherit from `BasePlugin`: |
| 21 | + |
| 22 | +```csharp |
| 23 | +using DevProxy.Abstractions.Plugins; |
| 24 | +using DevProxy.Abstractions.Proxy; |
| 25 | +using Microsoft.Extensions.Configuration; |
| 26 | +using Microsoft.Extensions.DependencyInjection; |
| 27 | + |
| 28 | +public class MyPlugin : BasePlugin |
| 29 | +{ |
| 30 | + public override string Name => nameof(MyPlugin); |
| 31 | + |
| 32 | + public MyPlugin( |
| 33 | + IPluginEvents pluginEvents, |
| 34 | + IProxyContext context, |
| 35 | + ISet<UrlToWatch> urlsToWatch, |
| 36 | + IConfigurationSection? configSection = null |
| 37 | + ) : base(pluginEvents, context, urlsToWatch, configSection) |
| 38 | + { |
| 39 | + } |
| 40 | + |
| 41 | + public override async Task BeforeRequestAsync( |
| 42 | + ProxyRequestArgs e, |
| 43 | + CancellationToken cancellationToken) |
| 44 | + { |
| 45 | + // Your custom logic here |
| 46 | + } |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +For more information, see the [Dev Proxy documentation](https://aka.ms/devproxy/docs). |
0 commit comments