public async Task Dispatch(HttpContext context, LayIMOptions options, RequestDelegate next) { if (context.IsLayIMResourceRequest(options)) { await next?.Invoke(context); } else { context.Response.StatusCode = StatusCodes.Status404NotFound; } }
public static IApplicationBuilder UseLayIM(this IApplicationBuilder app, Action <LayIMOptions> initFunc = null) { var options = new LayIMOptions(); initFunc?.Invoke(options); app.UseMiddleware <LayIMMiddleware>(options); app.UseFileServer(new FileServerOptions { RequestPath = options.ApiPrefix, FileProvider = new EmbeddedFileProvider(typeof(LayIMBuilderExtensions).GetTypeInfo().Assembly, LayIMEmbeddedFileNamespace), }); return(app); }