/// <summary>
    /// Configures the endpoints for all routes
    /// </summary>
    /// <param name="convention">The convention to add to the builder.</param>
    /// <returns></returns>
    public ReverseProxyConventionBuilder ConfigureEndpoints(Action <IEndpointConventionBuilder> convention)
    {
        _ = convention ?? throw new ArgumentNullException(nameof(convention));

        void Action(EndpointBuilder endpointBuilder)
        {
            var conventionBuilder = new EndpointBuilderConventionBuilder(endpointBuilder);

            convention(conventionBuilder);
        }

        Add(Action);

        return(this);
    }
    /// <summary>
    /// Configures the endpoints for all routes
    /// </summary>
    /// <param name="convention">The convention to add to the builder.</param>
    /// <returns></returns>
    public ReverseProxyConventionBuilder ConfigureEndpoints(Action <IEndpointConventionBuilder, RouteConfig> convention)
    {
        _ = convention ?? throw new ArgumentNullException(nameof(convention));

        void Action(EndpointBuilder endpointBuilder)
        {
            var route             = endpointBuilder.Metadata.OfType <RouteModel>().Single();
            var conventionBuilder = new EndpointBuilderConventionBuilder(endpointBuilder);

            convention(conventionBuilder, route.Config);
        }

        Add(Action);

        return(this);
    }
Beispiel #3
0
        /// <summary>
        /// Configures the endpoints for all routes
        /// </summary>
        /// <param name="convention">The convention to add to the builder.</param>
        /// <returns></returns>
        public ReverseProxyConventionBuilder ConfigureEndpoints(Action <IEndpointConventionBuilder, ProxyRoute, Cluster> convention)
        {
            _ = convention ?? throw new ArgumentNullException(nameof(convention));

            void Action(EndpointBuilder endpointBuilder)
            {
                var routeConfig = endpointBuilder.Metadata.OfType <RouteConfig>().Single();

                var cluster           = routeConfig.Cluster?.Config.Options;
                var proxyRoute        = routeConfig.ProxyRoute;
                var conventionBuilder = new EndpointBuilderConventionBuilder(endpointBuilder);

                convention(conventionBuilder, proxyRoute, cluster);
            }

            Add(Action);

            return(this);
        }