/// <summary>
        /// Initializes a new instance of the <see cref="OcelotSwaggerMiddleware"/> class.
        /// </summary>
        /// <param name="next">The next delegate.</param>
        /// <param name="options">The options.</param>
        /// <param name="reRoutes">The Ocelot ReRoutes configuration.</param>
        /// <param name="swaggerEndPoints">The swagger end points.</param>
        /// <param name="httpClientFactory">The HTTP client factory.</param>
        /// <param name="transformer"></param>
        public OcelotSwaggerMiddleware(RequestDelegate next, SwaggerForOCelotUIOptions options, IOptions <List <ReRouteOptions> > reRoutes, IOptions <List <SwaggerEndPointOptions> > swaggerEndPoints, IHttpClientFactory httpClientFactory, ISwaggerJsonTransformer transformer)
        {
            this.Transformer = Check.NotNull(transformer, nameof(transformer));
            this.Next        = Check.NotNull(next, nameof(next));
            this.ReRoutes    = Check.NotNull(reRoutes, nameof(reRoutes));
            Check.NotNull(swaggerEndPoints, nameof(swaggerEndPoints));
            this.HttpClientFactory = Check.NotNull(httpClientFactory, nameof(httpClientFactory));

            var value = swaggerEndPoints.Value;

            SwaggerEndPoints = new Lazy <Dictionary <string, SwaggerEndPointOptions> >(() => value.ToDictionary(p => $"/{p.KeyToPath}", p => p));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SwaggerForOcelotMiddleware"/> class.
 /// </summary>
 /// <param name="next">The next delegate.</param>
 /// <param name="options">The options.</param>
 /// <param name="routes">The Ocelot Routes configuration.</param>
 /// <param name="swaggerEndPoints">The swagger end points.</param>
 /// <param name="httpClientFactory">The HTTP client factory.</param>
 /// <param name="transformer">The SwaggerJsonTransformer</param>
 public SwaggerForOcelotMiddleware(
     RequestDelegate next,
     SwaggerForOcelotUIOptions options,
     IOptions <List <RouteOptions> > routes,
     ISwaggerJsonTransformer transformer,
     ISwaggerDownstreamInterceptor downstreamInterceptor = null)
 {
     _transformer           = Check.NotNull(transformer, nameof(transformer));
     _next                  = Check.NotNull(next, nameof(next));
     _routes                = Check.NotNull(routes, nameof(routes));
     _options               = options;
     _downstreamInterceptor = downstreamInterceptor;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SwaggerForOcelotMiddleware"/> class.
        /// </summary>
        /// <param name="next">The next delegate.</param>
        /// <param name="options">The options.</param>
        /// <param name="routes">The Ocelot Routes configuration.</param>
        /// <param name="swaggerEndPoints">The swagger end points.</param>
        /// <param name="httpClientFactory">The HTTP client factory.</param>
        /// <param name="transformer">The SwaggerJsonTransformer</param>
        public SwaggerForOcelotMiddleware(
            RequestDelegate next,
            SwaggerForOcelotUIOptions options,
            IOptions <List <RouteOptions> > routes,
            IOptions <List <SwaggerEndPointOptions> > swaggerEndPoints,
            IHttpClientFactory httpClientFactory,
            ISwaggerJsonTransformer transformer)
        {
            _transformer = Check.NotNull(transformer, nameof(transformer));
            _next        = Check.NotNull(next, nameof(next));
            _routes      = Check.NotNull(routes, nameof(routes));
            Check.NotNull(swaggerEndPoints, nameof(swaggerEndPoints));
            _httpClientFactory = Check.NotNull(httpClientFactory, nameof(httpClientFactory));
            _options           = options;

            _swaggerEndPoints = new Lazy <Dictionary <string, SwaggerEndPointOptions> >(()
                                                                                        => swaggerEndPoints.Value.ToDictionary(p => $"/{p.KeyToPath}", p => p));
        }