Skip to content

Instantly share code, notes, and snippets.

@renatogroffe
Created December 18, 2023 16:46
Show Gist options
  • Save renatogroffe/fa9a397b64b4531e596638a629d5644a to your computer and use it in GitHub Desktop.
Save renatogroffe/fa9a397b64b4531e596638a629d5644a to your computer and use it in GitHub Desktop.
namespace APIContagem.Middlewares;
public class MiddlewareExecutionNotificator
{
private readonly RequestDelegate _next;
public MiddlewareExecutionNotificator(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext httpContext)
{
var logger = (ILogger<MiddlewareExecutionNotificator>)httpContext
.RequestServices.GetService(typeof(ILogger<MiddlewareExecutionNotificator>))!;
logger.LogWarning("MiddlewareExecutionNotificator - Inicio da execucao");
await _next(httpContext);
logger.LogWarning("MiddlewareExecutionNotificator - Fim da execucao");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment