Skip to content

Releases: twitchax/AspNetCore.Proxy

AspNetCore.Proxy 3.1.0

09 Oct 20:33
aa1da30
Compare
Choose a tag to compare

This release adds a few features.

WebSocket Support

All proxying methods can now also proxy WebSocket requests by specifying a WebSocket endpoint.

app.UseProxy("/ws", "ws://mysite.com/ws");

RunProxy

You can now proxy over all endpoints.

app.RunProxy(context =>
{
    if(context.WebSockets.IsWebSocketRequest)
        return "wss://mysite.com/ws";

    return "https://mysite.com";
});

Custom HttpClient

Via AddProxies.

services.AddProxies(client => client.Timeout = TimeSpan.FromSeconds(10));

Via ProxyOptions.

this.ProxyAsync(
    $"https://jsonplaceholder.typicode.com/posts/{postId}",
    ProxyOptions.Instance.WithHttpClientName("CustomClient"));

Intercept Method

You can now intercept a proxy request in certain circumstances.

var options = ProxyOptions.Instance
    .WithIntercept(async context =>
    {
        if(c.Connection.RemotePort == 7777)
        {
            c.Response.StatusCode = 300;
            await c.Response.WriteAsync("I don't like this port, so I am not proxying this request!");
            return true;
        }

        return false;
    });

return this.ProxyAsync($"https://mysite.com", options);

AspNetCore.Proxy 3.0.1

05 Sep 23:35
9886485
Compare
Choose a tag to compare

This release allows the developer to add ProxyOptions to the proxied calls. These options instruct the proxier to perform specific actions during parts of the proxy operation, failures, etc.

This release is a breaking change. The handleFailure proxy parameter must now be supplied via the ProxyOptions.

public class MyController : Controller
{
    [Route("api/posts/{postId}")]
    public Task GetPosts(int postId)
    {
        var options = ProxyOptions.Instance
            .WithShouldAddForwardedHeaders(false)
            .WithBeforeSend((c, hrm) =>
            {
                // Set something that is needed for the downstream endpoint.
                hrm.Headers.Authorization = new AuthenticationHeaderValue("Basic");
            })
            .WithAfterReceive((c, hrm) =>
            {
                // Alter the conent in  some way before sending back to client.
                var newContent = new StringContent("It's all greek...er, Latin...to me!");
                hrm.Content = newContent;
            })
            .WithHandleFailure((c, e) =>
            {
                // Return a custom error response.
                c.Response.StatusCode = 403;
                c.Response.WriteAsync("Things borked.");
            });

        return this.ProxyAsync($"https://jsonplaceholder.typicode.com/posts/{postId}");
    }
}

AspNetCore.Proxy 2.1.2

15 Jun 19:45
66388e1
Compare
Choose a tag to compare

This release fixes a bug with proxied Content headers for form POST requests.

AspNetCore.Proxy 2.1.1

22 Apr 18:52
Compare
Choose a tag to compare

This release fixes a bug with proxied headers for GET, etc. operations.

AspNetCore.Proxy 2.1.0

15 Apr 08:39
916bea7
Compare
Choose a tag to compare

This release allows the developer to properly proxy form post data.

AspNetCore.Proxy 2.0.0

17 Mar 10:47
Compare
Choose a tag to compare

This release utilizes Microsoft.Extensions.Http for the underlying HttpClient creation.

There is a breaking change. The required services must now be applied in ConfigureServices.

public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddProxies();
    ...
}

AspNetCore.Proxy 1.4.1

16 Mar 22:47
Compare
Choose a tag to compare

Patch to Proxy from previous. Renamed to ProxyAsync. De-listed 1.4.0.

AspNetCore.Proxy 1.4.0

16 Mar 22:26
Compare
Choose a tag to compare

This release adds functionality to leverage the proxy helpers without introducing new concepts.

You can now proxy from an existing Controller by calling an extension method which proxies the call and writes the response automatically.

public class MyController : Controller
{
    [Route("api/posts/{postId}")]
    public Task GetPosts(int postId)
    {
        return this.Proxy($"https://jsonplaceholder.typicode.com/posts/{postId}");
    }
}

AspNetCore.Proxy v1.3.0

02 Jan 00:43
54933e4
Compare
Choose a tag to compare

Adds support for HttpContext access in callback.