33
44using System ;
55using System . Collections . Generic ;
6- using System . Linq ;
76using Microsoft . Extensions . Configuration ;
87
98namespace Microsoft . Azure . WebJobs . Script . Configuration
109{
1110 public sealed class HostConfigurationProfile
1211 {
13- public const string SectionKey = "configurationProfile" ;
12+ private const string SectionKey = "configurationProfile" ;
1413
1514 // note: profile name consts are intentionally private.
1615 // This ensures tests will fail if these values are changed without updating the test also.
1716 private const string DefaultProfile = "default" ;
1817
19- private const string McpCustomerHandlerProfile = "mcp-custom-handler" ;
18+ private const string McpCustomHandlerProfile = "mcp-custom-handler" ;
19+
20+ private const string WebAppCustomHandlerProfile = "web-app-custom-handler" ;
2021
2122 // Make sure to update this as new profiles are added.
22- private const string SupportedValues = $ "'', '{ DefaultProfile } ', '{ McpCustomerHandlerProfile } '";
23+ private const string SupportedValues = $ "'', '{ DefaultProfile } ', '{ McpCustomHandlerProfile } ', '{ WebAppCustomHandlerProfile } '";
24+
25+ private static readonly Dictionary < string , string > CommonHttpCustomHandlerConfiguration = new ( )
26+ {
27+ [ ConfigurationPath . Combine ( ConfigurationSectionNames . CustomHandler , ScriptConstants . EnableProxyingHttpRequest ) ] = "true" ,
28+ [ ConfigurationPath . Combine ( ConfigurationSectionNames . Http , "routePrefix" ) ] = string . Empty ,
29+ [ ConfigurationPath . Combine ( ConfigurationSectionNames . CustomHandler , "http" , "routes" , "0" , "route" ) ] = "{*route}"
30+ } ;
2331
2432 public static readonly HostConfigurationProfile Default = new ( DefaultProfile , [ ] ) ;
2533
26- public static readonly HostConfigurationProfile McpCustomHandler = new (
27- McpCustomerHandlerProfile ,
28- [
29- KeyValuePair . Create ( ConfigurationPath . Combine (
30- ConfigurationSectionNames . CustomHandler , ScriptConstants . EnableProxyingHttpRequest ) , "true" ) ,
31- KeyValuePair . Create ( ConfigurationPath . Combine (
32- ConfigurationSectionNames . Http , "routePrefix" ) , string . Empty ) ,
33- KeyValuePair . Create ( ConfigurationPath . Combine (
34- ConfigurationSectionNames . CustomHandler , "http" , "routes" , "0" , "route" ) , "{*route}" ) ,
35- ] ) ;
34+ public static readonly HostConfigurationProfile McpCustomHandler = new ( McpCustomHandlerProfile , CommonHttpCustomHandlerConfiguration ) ;
35+
36+ public static readonly HostConfigurationProfile WebAppCustomHandler = new ( WebAppCustomHandlerProfile , CommonHttpCustomHandlerConfiguration ) ;
3637
3738 private HostConfigurationProfile (
3839 string name ,
@@ -49,9 +50,11 @@ private HostConfigurationProfile(
4950 public static HostConfigurationProfile Get ( string name )
5051 {
5152 ArgumentNullException . ThrowIfNull ( name ) ;
53+
5254 return name . ToLowerInvariant ( ) switch
5355 {
54- McpCustomerHandlerProfile => McpCustomHandler ,
56+ McpCustomHandlerProfile => McpCustomHandler ,
57+ WebAppCustomHandlerProfile => WebAppCustomHandler ,
5558 "" or DefaultProfile => Default ,
5659 _ => throw new NotSupportedException (
5760 $ "Configuration profile '{ name } ' is not supported. Supported values: { SupportedValues } .") ,
0 commit comments