Created
August 11, 2016 14:45
-
-
Save Fodsuk/271edd5a68167a8aac47cdfb50154991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task Invoke(HttpContext context) | |
{ | |
var stopWatch = new Stopwatch(); | |
stopWatch.Start(); | |
context.Response.OnStarting(_ => | |
{ | |
((HttpContext)_).Response.Headers["X-Instrumentation-Time-Elapsed-Ms"] = stopWatch.ElapsedMilliseconds.ToString(); | |
return Task.FromResult(0); | |
}, context); | |
stopWatch.Stop(); | |
await _next(context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment