private static MidFunc Index(IndexResource index) { var response = index.Get(); Task Index(HttpContext context, Func <Task> next) => context.WriteResponse(response); return(Index); }
private static Action <IApplicationBuilder> Configure(IndexResource index) => builder => builder .UseMiddlewareLogging(typeof(IndexMiddleware)) .MapWhen(HttpMethod.Get, inner => inner.UseAccept(Constants.MediaTypes.HalJson).Use(Index(index))) .UseAllowedMethods(index);
public static IApplicationBuilder UseIndex(this IApplicationBuilder app, IndexResource index) => app.UseMiddlewareLogging(typeof(IndexMiddleware)) .MapWhen(HttpMethod.Get, inner => inner.UseAccept(Constants.MediaTypes.HalJson).Use(Index(index))) .UseAllowedMethods(index);
public static IApplicationBuilder UseIndex(this IApplicationBuilder builder, IndexResource index) => builder.MapWhen( IsMatch, Configure(index));