@@ -46,15 +46,15 @@ public void ConfigureServices(IServiceCollection services)
4646 public async Task HandleRequest ( HttpContext context , string requestBody , byte [ ] requestBodyBytes )
4747 {
4848 Debug . Assert ( context != null ) ;
49- var responseRegistryItem = _responseRegistry . Add ( new ResponseRegistryItem
49+ var responseRegistryItem = new ResponseRegistryItem
5050 {
5151 Timestamp = DateTime . Now ,
5252 RequestBody = requestBody ,
5353 Method = context . Request . Method ,
5454 RequestPath = context . Request . Path . ToString ( ) ,
5555 QueryString = context . Request . QueryString . ToString ( )
56- } ) ;
57- responseRegistryItem . WriteIncomingInfoToConsole ( ) ;
56+ } ;
57+ Debug . Assert ( responseRegistryItem . Id == 0 ) ;
5858
5959 try
6060 {
@@ -64,25 +64,35 @@ public async Task HandleRequest(HttpContext context, string requestBody, byte[]
6464 {
6565 Debug . WriteLine ( e ) ;
6666 responseRegistryItem . Error = e . ToString ( ) ;
67+ if ( ! responseRegistryItem . HasBeenAddedToRegistry )
68+ {
69+ _responseRegistry . AddAndWriteIncomingInfoToConsole ( responseRegistryItem ) ;
70+ }
6771 }
6872 finally
6973 {
70- responseRegistryItem . WriteResolvedInfoToConsole ( ) ;
74+ if ( responseRegistryItem . HasBeenAddedToRegistry )
75+ {
76+ responseRegistryItem . WriteResolvedInfoToConsole ( ) ;
77+ }
7178 }
7279
7380 }
7481
7582 public async Task HandleRequestInner ( ResponseRegistryItem responseRegistryItem , HttpContext context , string requestBody , byte [ ] requestBodyBytes )
7683 {
7784 Debug . Assert ( _endpointCollectionProvider != null ) ;
85+ Debug . Assert ( responseRegistryItem != null ) ;
7886 var endpointCollection = _endpointCollectionProvider . EndpointCollection ;
7987 var endpoint = endpointCollection . Resolve ( context . Request . Path . ToString ( ) ) ;
8088 responseRegistryItem . Endpoint = endpoint ;
8189 if ( endpoint != null )
82- {
90+ {
8391 var matcher_and_creator = endpoint . Resolve ( context . Request . Method , context . Request . Path , context . Request . QueryString , requestBody , context . Request . Headers ) ;
8492 if ( matcher_and_creator != null )
8593 {
94+ //TODO: Only if configured
95+ _responseRegistry . AddAndWriteIncomingInfoToConsole ( responseRegistryItem ) ;
8696 var responseCreator = matcher_and_creator . ResponseCreator ;
8797
8898 responseRegistryItem . RequestMatcher = matcher_and_creator . RequestMatcher ;
@@ -106,11 +116,13 @@ public async Task HandleRequestInner(ResponseRegistryItem responseRegistryItem,
106116 }
107117 else
108118 {
119+ _responseRegistry . AddAndWriteIncomingInfoToConsole ( responseRegistryItem ) ;
109120 responseRegistryItem . Error = "Endpoint has no match for request" ;
110121 }
111122 }
112123 else
113124 {
125+ _responseRegistry . AddAndWriteIncomingInfoToConsole ( responseRegistryItem ) ;
114126 responseRegistryItem . Error = "No endpoint matches request path" ;
115127 }
116128 }
0 commit comments