public ReDocMiddleware(
     RequestDelegate next,
     IHostingEnvironment hostingEnv,
     ILoggerFactory loggerFactory,
     ReDocOptions options)
 {
     _options = options ?? new ReDocOptions();
     _staticFileMiddleware = CreateStaticFileMiddleware(next, hostingEnv, loggerFactory, options);
 }
Esempio n. 2
0
        private StaticFileMiddleware CreateStaticFileMiddleware(
            RequestDelegate next,
            IHostingEnvironment hostingEnv,
            ILoggerFactory loggerFactory,
            ReDocOptions options)
        {
            var staticFileOptions = new StaticFileOptions
            {
                RequestPath  = string.IsNullOrEmpty(options.RoutePrefix) ? string.Empty : $"/{options.RoutePrefix}",
                FileProvider = new EmbeddedFileProvider(typeof(ReDocMiddleware).GetTypeInfo().Assembly, EmbeddedFileNamespace),
            };

            return(new StaticFileMiddleware(next, hostingEnv, Options.Create(staticFileOptions), loggerFactory));
        }
Esempio n. 3
0
        public ReDocMiddleware(
            RequestDelegate next,
            IHostingEnvironment hostingEnv,
            ILoggerFactory loggerFactory,
            ReDocOptions options)
        {
            _options = options ?? new ReDocOptions();

            _staticFileMiddleware = CreateStaticFileMiddleware(next, hostingEnv, loggerFactory, options);

            _jsonSerializerOptions = new JsonSerializerOptions();
            _jsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
            _jsonSerializerOptions.IgnoreNullValues     = true;
            _jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase, false));
        }
 public ReDocIndexMiddleware(RequestDelegate next, ReDocOptions options)
 {
     _next    = next;
     _options = options;
 }