Beispiel #1
0
        private StaticFileMiddleware CreateStaticFileMiddleware(
            RequestDelegate next,
            IWebHostEnvironment hostingEnv,
            ILoggerFactory loggerFactory,
            ChoreographyOptions options)
        {
            var staticFileOptions = new StaticFileOptions
            {
                RequestPath  = string.IsNullOrEmpty(options.RoutePrefix) ? string.Empty : $"/{options.RoutePrefix}",
                FileProvider = new EmbeddedFileProvider(typeof(ChoreographyOptions).GetTypeInfo().Assembly, EmbeddedFileNamespace),
            };

            return(new StaticFileMiddleware(next, hostingEnv, Options.Create(staticFileOptions), loggerFactory));
        }
Beispiel #2
0
        public ChoreographyMiddleware(
            RequestDelegate next,
            IWebHostEnvironment hostingEnv,
            ILoggerFactory loggerFactory,
            ChoreographyOptions options,
            IChoreographyDescriptor choreographyDescriptor)
        {
            _options = options ?? new ChoreographyOptions();

            _choreographyDescriptor = choreographyDescriptor;
            _staticFileMiddleware   = CreateStaticFileMiddleware(next, hostingEnv, loggerFactory, options);
            _jsonSerializerOptions  = new JsonSerializerOptions();
            _jsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
            _jsonSerializerOptions.IgnoreNullValues     = false;
            _jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase, false));
        }