Beispiel #1
0
        internal static EndpointComputerToValueTask GetRunProxyComputer(EndpointComputerToValueTask endpointComputer)
        {
            return(async(context, args) =>
            {
                var endpoint = await GetEndpointFromComputerAsync(context, endpointComputer).ConfigureAwait(false);

                return $"{endpoint}{context.Request.Path}{context.Request.QueryString}";
            });
        }
Beispiel #2
0
        internal static EndpointComputerToValueTask GetRunProxyComputer(EndpointComputerToValueTask endpointComputer)
        {
            return(async(context, args) =>
            {
                var endpoint = await GetEndpointFromComputerAsync(context, endpointComputer).ConfigureAwait(false);

                // Remove trailing slashes when `RunProxy` endpoints are computed, since paths are appended ot them.
                endpoint = endpoint.TrimTrailingSlashes();

                return $"{endpoint}{context.Request.Path}{context.Request.QueryString}";
            });
        }
Beispiel #3
0
 /// <summary>
 /// Terminating middleware which creates a proxy over a specified endpoint.
 /// </summary>
 /// <param name="app">The ASP.NET <see cref="IApplicationBuilder"/>.</param>
 /// <param name="httpEndpointComputer">The HTTP endpoint to use.  This takes the form `(<see cref="HttpContext"/>, <see cref="IDictionary{String, Object}"/>) => <see cref="ValueTask{String}"/>`.</param>
 /// <param name="wsEndpointComputer">The WS endpoint to use.  This takes the form `(<see cref="HttpContext"/>, <see cref="IDictionary{String, Object}"/>) => <see cref="ValueTask{String}"/>`.</param>
 /// <param name="httpBuilderOptionsAction">The HTTP options builder action to use.  This takes the form `(<see cref="IHttpProxyOptionsBuilder"/>) => void`.</param>
 /// <param name="wsBuilderOptionsAction">The WS options builder action to use.  This takes the form `(<see cref="IWsProxyOptionsBuilder"/>) => void`.</param>
 public static void RunProxy(
     this IApplicationBuilder app,
     EndpointComputerToValueTask httpEndpointComputer,
     EndpointComputerToValueTask wsEndpointComputer,
     Action <IHttpProxyOptionsBuilder> httpBuilderOptionsAction = null,
     Action <IWsProxyOptionsBuilder> wsBuilderOptionsAction     = null)
 {
     app.RunProxy(builder => builder
                  .UseHttp(httpBuilder => httpBuilder
                           .WithEndpoint(httpEndpointComputer)
                           .WithOptions(httpBuilderOptionsAction)
                           )
                  .UseWs(wsBuilder => wsBuilder
                         .WithEndpoint(wsEndpointComputer)
                         .WithOptions(wsBuilderOptionsAction)
                         )
                  );
 }
Beispiel #4
0
 /// <inheritdoc/>
 public IHttpProxyBuilder WithEndpoint(EndpointComputerToValueTask endpointComputer)
 {
     _endpointComputer = endpointComputer;
     return(this);
 }
Beispiel #5
0
 internal HttpProxy(EndpointComputerToValueTask endpointComputer, HttpProxyOptions options)
 {
     EndpointComputer = endpointComputer;
     Options          = options;
 }
Beispiel #6
0
 internal static ValueTask <string> GetEndpointFromComputerAsync(this HttpContext context, EndpointComputerToValueTask computer) => computer(context, context.GetRouteData().Values);
Beispiel #7
0
 /// <summary>
 /// Terminating middleware which creates a proxy over a specified endpoint.
 /// </summary>
 /// <param name="app">The ASP.NET <see cref="IApplicationBuilder"/>.</param>
 /// <param name="wsEndpointComputer">The WS endpoint to use.  This takes the form `(<see cref="HttpContext"/>, <see cref="IDictionary{String, Object}"/>) => <see cref="ValueTask{String}"/>`.</param>
 /// <param name="wsBuilderOptionsAction">The WS options builder action to use.  This takes the form `(<see cref="IWsProxyOptionsBuilder"/>) => void`.</param>
 public static void RunWsProxy(this IApplicationBuilder app, EndpointComputerToValueTask wsEndpointComputer, Action <IWsProxyOptionsBuilder> wsBuilderOptionsAction = null) =>
 app.RunWsProxy(builder => builder
                .WithEndpoint(wsEndpointComputer)
                .WithOptions(wsBuilderOptionsAction)
                );
Beispiel #8
0
 /// <summary>
 /// Terminating middleware which creates a proxy over a specified endpoint.
 /// </summary>
 /// <param name="app">The ASP.NET <see cref="IApplicationBuilder"/>.</param>
 /// <param name="httpEndpointComputer">The HTTP endpoint to use.  This takes the form `(<see cref="HttpContext"/>, <see cref="IDictionary{String, Object}"/>) => <see cref="ValueTask{String}"/>`.</param>
 /// <param name="httpBuilderOptionsAction">The HTTP options builder action to use.  This takes the form `(<see cref="IHttpProxyOptionsBuilder"/>) => void`.</param>
 public static void RunHttpProxy(this IApplicationBuilder app, EndpointComputerToValueTask httpEndpointComputer, Action <IHttpProxyOptionsBuilder> httpBuilderOptionsAction = null) =>
 app.RunHttpProxy(builder => builder
                  .WithEndpoint(httpEndpointComputer)
                  .WithOptions(httpBuilderOptionsAction)
                  );
Beispiel #9
0
 /// <inheritdoc/>
 public IProxyBuilder UseWs(EndpointComputerToValueTask endpointComputer, Action <IWsProxyOptionsBuilder> builderAction = null) => this.UseWs(wsProxy => wsProxy.WithEndpoint(endpointComputer).WithOptions(builderAction));
Beispiel #10
0
 /// <inheritdoc/>
 public IProxyBuilder UseHttp(EndpointComputerToValueTask endpointComputer, Action <IHttpProxyOptionsBuilder> builderAction = null) => this.UseHttp(httpProxy => httpProxy.WithEndpoint(endpointComputer).WithOptions(builderAction));