using Bit.Core.Services; using Microsoft.AspNetCore.Http; namespace Bit.SharedWeb.Utilities; /// /// Middleware to extract the x-play-id header and set it in the PlayIdService. /// /// PlayId is used in testing infrastructure to track data created during automated testing and fa cilitate cleanup. /// /// public sealed class PlayIdMiddleware(RequestDelegate next) { public Task Invoke(HttpContext context, PlayIdService playIdService) { if (context.Request.Headers.TryGetValue("x-play-id", out var playId)) { playIdService.PlayId = playId; } return next(context); } }