@@ -46,7 +46,6 @@ public class WebScriptHostManager : ScriptHostManager
4646 private readonly WebJobsSdkExtensionHookProvider _bindingWebHookProvider ;
4747
4848 private bool _hostStarted = false ;
49- private IDictionary < IHttpRoute , FunctionDescriptor > _httpFunctions ;
5049 private HttpRouteCollection _httpRoutes ;
5150 private HttpRequestManager _httpRequestManager ;
5251
@@ -147,11 +146,11 @@ public static bool InStandbyMode
147146 }
148147 }
149148
150- public IReadOnlyDictionary < IHttpRoute , FunctionDescriptor > HttpFunctions
149+ public HttpRouteCollection Routes
151150 {
152151 get
153152 {
154- return _httpFunctions as IReadOnlyDictionary < IHttpRoute , FunctionDescriptor > ;
153+ return _httpRoutes ;
155154 }
156155 }
157156
@@ -283,7 +282,7 @@ public FunctionDescriptor GetHttpFunctionOrNull(HttpRequestMessage request)
283282 throw new ArgumentNullException ( nameof ( request ) ) ;
284283 }
285284
286- if ( _httpFunctions == null || _httpFunctions . Count == 0 )
285+ if ( _httpRoutes == null || _httpRoutes . Count == 0 )
287286 {
288287 return null ;
289288 }
@@ -292,7 +291,7 @@ public FunctionDescriptor GetHttpFunctionOrNull(HttpRequestMessage request)
292291 var routeData = _httpRoutes . GetRouteData ( request ) ;
293292 if ( routeData != null )
294293 {
295- _httpFunctions . TryGetValue ( routeData . Route , out function ) ;
294+ function = ( FunctionDescriptor ) routeData . Route . DataTokens [ ScriptConstants . AzureFunctionsHttpFunctionKey ] ;
296295 AddRouteDataToRequest ( routeData , request ) ;
297296 }
298297
@@ -390,30 +389,16 @@ private void InitializeHttpFunctions(IEnumerable<FunctionDescriptor> functions,
390389 // Proxies do not honor the route prefix defined in host.json
391390 var proxyHttpRouteFactory = new HttpRouteFactory ( string . Empty ) ;
392391
393- _httpFunctions = new Dictionary < IHttpRoute , FunctionDescriptor > ( ) ;
394392 _httpRoutes = new HttpRouteCollection ( ) ;
395393
396394 // Proxy routes will take precedence over http trigger functions and http trigger
397395 // 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 ) ;
399397
400- foreach ( var function in orderdFunctions )
398+ foreach ( var function in orderedFunctions )
401399 {
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 ) ;
417402 }
418403 }
419404
0 commit comments