private StaticFileMiddleware CreateStaticFileMiddleware( RequestDelegate next, IWebHostEnvironment hostingEnv, ILoggerFactory loggerFactory, Knife4UIOptions options) { var staticFileOptions = new StaticFileOptions { RequestPath = string.IsNullOrEmpty(options.RoutePrefix) ? string.Empty : $"/{options.RoutePrefix}", FileProvider = new EmbeddedFileProvider(typeof(Knife4jUIMiddleware).GetTypeInfo().Assembly, EmbeddedFileNamespace), }; return(new StaticFileMiddleware(next, hostingEnv, Options.Create(staticFileOptions), loggerFactory)); }
public Knife4jUIMiddleware( RequestDelegate next, IWebHostEnvironment hostingEnv, ILoggerFactory loggerFactory, Knife4UIOptions options) { _options = options ?? new Knife4UIOptions(); _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 static IApplicationBuilder UseKnife4UI( this IApplicationBuilder app, Action <Knife4UIOptions> setupAction = null) { var options = new Knife4UIOptions(); if (setupAction != null) { setupAction(options); } else { options = app.ApplicationServices.GetRequiredService <IOptions <Knife4UIOptions> >().Value; } app.UseMiddleware <Knife4jUIMiddleware>(options); return(app); }