private static Action <IApplicationBuilder> Configure(AllStreamMessageResource allStreamMessages) => builder => builder .UseMiddlewareLogging(typeof(AllStreamMessageMiddleware)) .MapWhen( HttpMethod.Get, inner => inner.UseAccept(Constants.MediaTypes.HalJson).Use(GetStreamMessage(allStreamMessages))) .UseAllowedMethods(allStreamMessages);
private static MidFunc GetStreamMessage(AllStreamMessageResource allStreamMessages) => async(context, next) => { var response = await allStreamMessages.Get( new ReadAllStreamMessageOperation(context), context.RequestAborted); await context.WriteResponse(response); };
public static IApplicationBuilder UseAllStreamMessage( this IApplicationBuilder builder, AllStreamMessageResource allStreamMessages) => builder .UseMiddlewareLogging(typeof(AllStreamMessageMiddleware)) .MapWhen( HttpMethod.Get, inner => inner.UseAccept(Constants.MediaTypes.HalJson).Use(GetStreamMessage(allStreamMessages))) .UseAllowedMethods(allStreamMessages);
public static IApplicationBuilder UseAllStreamMessage( this IApplicationBuilder builder, AllStreamMessageResource allStreamMessageResource) => builder.MapWhen(IsMatch, Configure(allStreamMessageResource));