Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NetCoreStack/Proxy
The type-safe REST library for .NET Standard 2.0 (NetCoreStack Flying Proxy)
https://github.com/NetCoreStack/Proxy
backend dotnet http-client load-balancer proxy rest-client scalability
Last synced: 9 days ago
JSON representation
The type-safe REST library for .NET Standard 2.0 (NetCoreStack Flying Proxy)
- Host: GitHub
- URL: https://github.com/NetCoreStack/Proxy
- Owner: NetCoreStack
- Created: 2016-12-25T18:28:23.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-10T12:52:16.000Z (about 1 year ago)
- Last Synced: 2024-08-01T02:25:19.460Z (3 months ago)
- Topics: backend, dotnet, http-client, load-balancer, proxy, rest-client, scalability
- Language: C#
- Homepage:
- Size: 1.07 MB
- Stars: 42
- Watchers: 7
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-dotnet-core - NetCoreStack.Proxy - The type-safe, distributed REST library for .NET Standard 2.0 (NetCoreStack Flying Proxy) (Frameworks, Libraries and Tools / API)
- fucking-awesome-dotnet-core - NetCoreStack.Proxy - The type-safe, distributed REST library for .NET Standard 2.0 (NetCoreStack Flying Proxy) (Frameworks, Libraries and Tools / API)
- awesome-dotnet-core - NetCoreStack.Proxy - The type-safe, distributed REST library for .NET Standard 2.0 (NetCoreStack Flying Proxy) (Frameworks, Libraries and Tools / API)
- awesome-dotnet-core - NetCoreStack.Proxy - 适用于.NET Standard 2.0的类型安全的分布式REST库(NetCoreStack Flying Proxy) (框架, 库和工具 / API)
README
# NetCoreStack Proxy
[![NuGet](https://img.shields.io/nuget/v/NetCoreStack.Proxy.svg?longCache=true&style=flat-square)](https://www.nuget.org/packages/NetCoreStack.Proxy)
[![NuGet](https://img.shields.io/nuget/dt/NetCoreStack.Proxy.svg?longCache=true&style=flat-square)](https://www.nuget.org/packages/NetCoreStack.Proxy)### Cross-Platform .NET Standard HTTP Base Flying Proxy
This project is demonstrating manage and consume distributed HTTP APIs and Micro Services
from different regions (hosts) with ease.Flying Proxy allows the management of scalable applications, trigger many operations at the same time from your clients (Desktop, Web or Mobile App) and start to consume your new resources that you can simply add.
Flying Proxy aims to:
- Simple scalability
- Effective and type-safe management of distributed architecture
- Better performance
- Maintainability## Sample Client (Web)
### Add ProxySettings section to the appsettings.json
```json
"ProxySettings": {
"RegionKeys": {
"Main": "http://localhost:5000/,http://localhost:5001/",
"Authorization": "http://localhost:5002/",
"Integrations": "http://localhost:5003/"
}
}
```### APIs Definitions
```csharp
// This API expose methods from localhost:5000 and localhost:5001 as configured on ProxySettings
[ApiRoute("api/[controller]", regionKey: "Main")]
public interface IGuidelineApi : IApiContract
{
[HttpHeaders("X-Method-Header: Some Value")]
Task TaskOperation();int PrimitiveReturn(int i, string s, long l, DateTime dt);
Task> GetEnumerableModels();
Task GetWithReferenceType(SimpleModel model);
///
/// Default Content-Type is ModelAware.
/// If the any parameter(s) has FormFile type property that will be MultipartFormData
/// if not will be JSON
///
///
///
[HttpPostMarker]
Task TaskActionPost(ComplexTypeModel model);[HttpPostMarker(ContentType = ContentType.MultipartFormData)]
Task TaskActionBarMultipartFormData(Bar model);[HttpPostMarker(ContentType = ContentType.Xml)]
Task TaskActionBarSimpleXml(BarSimple model);///
/// Template and parameter usage, key parameter will be part of the request Url
/// and extracting it as api/guideline/kv/
///
///
///
///
[HttpPutMarker(Template = "kv/{key}")]
Task CreateOrUpdateKey(string key, Bar body);
}
```### Startup ConfigureServices
```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddNetCoreProxy(Configuration, options =>
{
// Register the API to use as a Proxy
options.Register();
});// Add framework services.
services.AddMvc();
}
```### Proxy Usage (DI)
```csharp
public class HomeController : Controller
{
private readonly IGuidelineApi _api;public TestController(IGuidelineApi api)
{
_api = api;
}public async Task> GetModels()
{
var items = await _api.GetEnumerableModels();
return items;
}
}
```## Sample Server
### API Implementation
```csharp
[Route("api/[controller]")]
public class GuidelineController : Controller, IGuidelineApi
{
[HttpGet(nameof(GetEnumerableModels))]
public Task> GetEnumerableModels()
{
...
return items;
}[HttpPost(nameof(TaskComplexTypeModel))]
public async Task TaskComplexTypeModel([FromBody]ComplexTypeModel model)
{
...
}[HttpPost(nameof(TaskActionBarMultipartFormData))]
public Task TaskActionBarMultipartFormData(Bar model)
{
...
}[HttpPut("kv")]
public async Task CreateOrUpdateKey(string key, Bar body)
{
...
}
}
```### Unit Testing
Use [HttpLive](https://github.com/gencebay/httplive)httplive -p 5003,5004 -d test/NetCoreStack.Proxy.Tests/httplive.db
[Latest release on Nuget](https://www.nuget.org/packages/NetCoreStack.Proxy/)
### Prerequisites
> [ASP.NET Core](https://github.com/aspnet/Home)