1+ using System ;
12using System . Threading . Tasks ;
23using Microsoft . AspNetCore . Http ;
34using OneGround . ZGW . Common . Extensions ;
5+ using OneGround . ZGW . Common . Web . Versioning ;
46using Serilog ;
57using Serilog . Context ;
68
@@ -19,6 +21,8 @@ public EnrichedLoggingMiddleware(RequestDelegate next, IDiagnosticContext diagno
1921
2022 public async Task InvokeAsync ( HttpContext context )
2123 {
24+ var apiVersion = context . GetRequestedZgwApiVersion ( ) ? . ToString ( ) ?? String . Empty ;
25+
2226 var rsin = context . GetRsin ( ) ;
2327 var clientId = context . GetClientId ( ) ;
2428 var userId = context . GetUserId ( ) ;
@@ -30,13 +34,15 @@ public async Task InvokeAsync(HttpContext context)
3034 _diagnosticContext . Set ( "User" , user ) ;
3135 _diagnosticContext . Set ( "RequestHost" , context . Request . Host . Value ) ;
3236 _diagnosticContext . Set ( "RequestScheme" , context . Request . Scheme ) ;
37+ _diagnosticContext . Set ( "ApiVersion" , apiVersion ) ;
3338
3439 using var logRsin = LogContext . PushProperty ( "RSIN" , rsin ) ;
3540 using var logClientId = LogContext . PushProperty ( "ClientId" , clientId ) ;
3641 using var logUserId = LogContext . PushProperty ( "UserId" , userId ) ;
3742 using var logUser = LogContext . PushProperty ( "User" , user ) ;
3843 using var logHost = LogContext . PushProperty ( "RequestHost" , context . Request . Host . Value ) ;
3944 using var logSchema = LogContext . PushProperty ( "RequestScheme" , context . Request . Scheme ) ;
45+ using var logApiVersion = LogContext . PushProperty ( "ApiVersion" , apiVersion ) ;
4046
4147 await _next ( context ) ;
4248 }
0 commit comments