@@ -46,7 +46,6 @@ public class WebScriptHostManager : ScriptHostManager
46
46
private readonly WebJobsSdkExtensionHookProvider _bindingWebHookProvider ;
47
47
48
48
private bool _hostStarted = false ;
49
- private IDictionary < IHttpRoute , FunctionDescriptor > _httpFunctions ;
50
49
private HttpRouteCollection _httpRoutes ;
51
50
private HttpRequestManager _httpRequestManager ;
52
51
@@ -147,11 +146,11 @@ public static bool InStandbyMode
147
146
}
148
147
}
149
148
150
- public IReadOnlyDictionary < IHttpRoute , FunctionDescriptor > HttpFunctions
149
+ public HttpRouteCollection Routes
151
150
{
152
151
get
153
152
{
154
- return _httpFunctions as IReadOnlyDictionary < IHttpRoute , FunctionDescriptor > ;
153
+ return _httpRoutes ;
155
154
}
156
155
}
157
156
@@ -283,7 +282,7 @@ public FunctionDescriptor GetHttpFunctionOrNull(HttpRequestMessage request)
283
282
throw new ArgumentNullException ( nameof ( request ) ) ;
284
283
}
285
284
286
- if ( _httpFunctions == null || _httpFunctions . Count == 0 )
285
+ if ( _httpRoutes == null || _httpRoutes . Count == 0 )
287
286
{
288
287
return null ;
289
288
}
@@ -292,7 +291,7 @@ public FunctionDescriptor GetHttpFunctionOrNull(HttpRequestMessage request)
292
291
var routeData = _httpRoutes . GetRouteData ( request ) ;
293
292
if ( routeData != null )
294
293
{
295
- _httpFunctions . TryGetValue ( routeData . Route , out function ) ;
294
+ function = ( FunctionDescriptor ) routeData . Route . DataTokens [ ScriptConstants . AzureFunctionsHttpFunctionKey ] ;
296
295
AddRouteDataToRequest ( routeData , request ) ;
297
296
}
298
297
@@ -390,30 +389,16 @@ private void InitializeHttpFunctions(IEnumerable<FunctionDescriptor> functions,
390
389
// Proxies do not honor the route prefix defined in host.json
391
390
var proxyHttpRouteFactory = new HttpRouteFactory ( string . Empty ) ;
392
391
393
- _httpFunctions = new Dictionary < IHttpRoute , FunctionDescriptor > ( ) ;
394
392
_httpRoutes = new HttpRouteCollection ( ) ;
395
393
396
394
// Proxy routes will take precedence over http trigger functions and http trigger
397
395
// routes so they will be added first to the list of http routes.
398
- var orderdFunctions = functions . OrderBy ( f => f . Metadata . IsProxy ? 0 : 1 ) ;
396
+ var orderedFunctions = functions . OrderBy ( f => f . Metadata . IsProxy ? 0 : 1 ) ;
399
397
400
- foreach ( var function in orderdFunctions )
398
+ foreach ( var function in orderedFunctions )
401
399
{
402
- var httpTrigger = function . GetTriggerAttributeOrNull < HttpTriggerAttribute > ( ) ;
403
- if ( httpTrigger != null )
404
- {
405
- IHttpRoute httpRoute = null ;
406
- IEnumerable < HttpMethod > httpMethods = null ;
407
- if ( httpTrigger . Methods != null )
408
- {
409
- httpMethods = httpTrigger . Methods . Select ( p => new HttpMethod ( p ) ) . ToArray ( ) ;
410
- }
411
- var httpRouteFactory = function . Metadata . IsProxy ? proxyHttpRouteFactory : functionHttpRouteFactory ;
412
- if ( httpRouteFactory . TryAddRoute ( function . Metadata . Name , httpTrigger . Route , httpMethods , _httpRoutes , out httpRoute ) )
413
- {
414
- _httpFunctions . Add ( httpRoute , function ) ;
415
- }
416
- }
400
+ var httpRouteFactory = function . Metadata . IsProxy ? proxyHttpRouteFactory : functionHttpRouteFactory ;
401
+ httpRouteFactory . TryAddRoute ( _httpRoutes , function ) ;
417
402
}
418
403
}
419
404
0 commit comments