RestProxy 1.0.2
See the version list below for details.
dotnet add package RestProxy --version 1.0.2
NuGet\Install-Package RestProxy -Version 1.0.2
<PackageReference Include="RestProxy" Version="1.0.2" />
<PackageVersion Include="RestProxy" Version="1.0.2" />
<PackageReference Include="RestProxy" />
paket add RestProxy --version 1.0.2
#r "nuget: RestProxy, 1.0.2"
#:package RestProxy@1.0.2
#addin nuget:?package=RestProxy&version=1.0.2
#tool nuget:?package=RestProxy&version=1.0.2
RestProxy
Proxy generator for .NET HTTP clients, which connect to an ASP.NET Core server.
https://github.com/ja3cob/RestProxy
Remarks
This package is still in development and definitely misses some features. If you would like to propose something you can create an issue on GitHub
Usage
Generate an interface representing your controller in ASP.NET Core server, but use types from ASPClientLib package (this allows support on all platforms because ASP.NET Core framework sometimes cannot be referenced). Controller interface must include at least RouteAttribute on the interface or actions and HttpMethodAttribute on all actions.
Example:
AuthenticationController ASP.NET Controller:
[ApiController] [RouteApiController("[action]")] public class AuthenticationController(AuthService service) : ControllerBase { [HttpPost] [AllowAnonymous] public async Task<ActionResult<bool>> Login([FromBody] LoginRequest request) { var principal = service.TryGetPrincipal(request); if (principal == null) { return Unauthorized(false); } await HttpContext.SignInAsync(principal); return Ok(true); } }Note that in order for this controller to work, types (HttpPost, IActionResult, etc.) are from the ASP.NET Core framework.
IAuthenticationController interface:
[RouteApiController("[action]")] public interface IAuthenticationController { [HttpPost] Task<ActionResult<bool>> Login([FromBody] LoginRequest request); }Note that the interface uses types from the ASPClientLib package to mantain support on all client platforms
Reference RestProxy and your controller interface (here IAutenticationController) in your client project.
Create a new instance of the RestProxyManager class, providing base url of the server as the constructor parameter. Use the manager to get proxy and send request to the server
var manager = new RestProxyManager("https://localhost:5000/"); var proxy = manager.GetProxy<IAuthenticationController>(); bool result = (await proxy.Login(new LoginRequest(username, password))).Value;
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- ASPClientLib (>= 1.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.2 | 218 | 5/7/2025 |
| 1.2.1 | 239 | 3/3/2025 |
| 1.2.0 | 165 | 1/21/2025 |
| 1.1.3 | 210 | 11/30/2024 |
| 1.1.1 | 167 | 9/9/2024 |
| 1.1.0 | 158 | 8/6/2024 |
| 1.0.11 | 152 | 7/23/2024 |
| 1.0.10 | 170 | 7/17/2024 |
| 1.0.9 | 166 | 7/17/2024 |
| 1.0.8 | 174 | 7/17/2024 |
| 1.0.7 | 162 | 7/17/2024 |
| 1.0.6 | 174 | 6/28/2024 |
| 1.0.5 | 181 | 6/25/2024 |
| 1.0.4 | 165 | 6/25/2024 |
| 1.0.3 | 161 | 6/25/2024 |
| 1.0.2 | 166 | 6/24/2024 |
| 1.0.1 | 177 | 6/24/2024 |
| 1.0.0 | 168 | 6/24/2024 |