1- using System ;
2- using System . IO ;
3- using System . Reflection ;
41using System . Threading . Tasks ;
52using GeneXus . Cache ;
6- using GeneXus . Deploy . AzureFunctions . HttpHandler ;
3+ using GeneXus . Deploy . AzureFunctions . Handlers . Helpers ;
74using GxClasses . Web ;
8- using GxClasses . Web . Middleware ;
9- using Microsoft . AspNetCore . Http ;
105using Microsoft . Azure . Functions . Worker ;
116using Microsoft . Azure . Functions . Worker . Http ;
12- using Microsoft . Extensions . Logging ;
137using HttpRequestData = Microsoft . Azure . Functions . Worker . Http . HttpRequestData ;
148
159namespace GeneXus . Deploy . AzureFunctions . GAM
@@ -19,112 +13,101 @@ public class GAMAzureFunctions
1913 private IGXRouting _gxRouting ;
2014 private ICacheService2 _redis ;
2115
16+ private ProxyServices _proxyServices ;
17+
2218 public GAMAzureFunctions ( IGXRouting gxRouting , ICacheService2 redis )
2319 {
2420 _gxRouting = gxRouting ;
2521 if ( redis != null && redis . GetType ( ) == typeof ( Redis ) )
2622 _redis = redis ;
23+ _proxyServices = new ProxyServices ( _gxRouting , _redis ) ;
2724 }
2825
26+
2927 [ Function ( "oauth_access_token" ) ]
3028 public async Task < HttpResponseData > Accesstoken ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/access_token" ) ] HttpRequestData req ,
3129 FunctionContext executionContext )
3230 {
33- return await ExecuteHttpFunction ( req , executionContext ) ;
31+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
3432 }
3533
3634 [ Function ( "oauth_logout" ) ]
3735 public async Task < HttpResponseData > Logout ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/logout" ) ] HttpRequestData req ,
3836 FunctionContext executionContext )
3937 {
40- return await ExecuteHttpFunction ( req , executionContext ) ;
38+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
4139 }
4240
4341 [ Function ( "oauth_userinfo" ) ]
4442 public async Task < HttpResponseData > UserInfo ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/userinfo" ) ] HttpRequestData req ,
4543 FunctionContext executionContext )
4644 {
47- return await ExecuteHttpFunction ( req , executionContext ) ;
45+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
4846 }
4947
5048 [ Function ( "oauth_gam_signin" ) ]
5149 public async Task < HttpResponseData > Signin ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/gam/signin" ) ] HttpRequestData req ,
5250 FunctionContext executionContext )
5351 {
54- return await ExecuteHttpFunction ( req , executionContext ) ;
52+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
5553 }
5654
5755 [ Function ( "oauth_gam_callback" ) ]
5856 public async Task < HttpResponseData > Callback ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/gam/callback" ) ] HttpRequestData req ,
5957 FunctionContext executionContext )
6058 {
61- return await ExecuteHttpFunction ( req , executionContext ) ;
59+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
6260 }
6361
6462 [ Function ( "oauth_gam_access_token" ) ]
6563 public async Task < HttpResponseData > GAMAccessToken ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/gam/access_token" ) ] HttpRequestData req ,
6664 FunctionContext executionContext )
6765 {
68- return await ExecuteHttpFunction ( req , executionContext ) ;
66+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
6967 }
7068
7169 [ Function ( "oauth_gam_userinfo" ) ]
7270 public async Task < HttpResponseData > GAMUserInfo ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/gam/userinfo" ) ] HttpRequestData req ,
7371 FunctionContext executionContext )
7472 {
75- return await ExecuteHttpFunction ( req , executionContext ) ;
73+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
7674 }
7775
7876 [ Function ( "oauth_gam_signout" ) ]
7977 public async Task < HttpResponseData > GAMSignout ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/gam/signout" ) ] HttpRequestData req ,
8078 FunctionContext executionContext )
8179 {
82- return await ExecuteHttpFunction ( req , executionContext ) ;
80+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
8381 }
8482
8583 [ Function ( "oauth_RequestTokenService" ) ]
8684 public async Task < HttpResponseData > RequestTokenService ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/RequestTokenService" ) ] HttpRequestData req ,
8785 FunctionContext executionContext )
8886 {
89- return await ExecuteHttpFunction ( req , executionContext ) ;
87+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
9088 }
9189
9290 [ Function ( "oauth_QueryAccessToken" ) ]
9391 public async Task < HttpResponseData > QueryAccessToken ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "oauth/QueryAccessToken" ) ] HttpRequestData req ,
9492 FunctionContext executionContext )
9593 {
96- return await ExecuteHttpFunction ( req , executionContext ) ;
94+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
9795 }
9896
9997 [ Function ( "saml_gam_signout" ) ]
10098 public async Task < HttpResponseData > SAMLGAMSignout ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "saml/gam/signout" ) ] HttpRequestData req ,
10199 FunctionContext executionContext )
102100 {
103- return await ExecuteHttpFunction ( req , executionContext ) ;
101+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
104102 }
105103
106104 [ Function ( "saml_gam_callback" ) ]
107105 public async Task < HttpResponseData > SAMLGAMCallback ( [ HttpTrigger ( AuthorizationLevel . Anonymous , "get" , "post" , Route = "saml/gam/callback" ) ] HttpRequestData req ,
108106 FunctionContext executionContext )
109107 {
110- return await ExecuteHttpFunction ( req , executionContext ) ;
108+ return await _proxyServices . ExecuteHttpFunction ( req , executionContext ) ;
111109 }
112110
113- private async Task < HttpResponseData > ExecuteHttpFunction ( HttpRequestData req , FunctionContext executionContext )
114- {
115-
116- var logger = executionContext . GetLogger ( "GAMAzureFunctions" ) ;
117- logger . LogInformation ( $ "GeneXus Http trigger handler. Function processed: { executionContext . FunctionDefinition . Name } .") ;
118-
119- HttpResponseData httpResponseData = req . CreateResponse ( ) ;
120- HttpContext httpAzureContextAccessor = new GXHttpAzureContextAccessor ( req , httpResponseData , _redis ) ;
121-
122- GXRouting . ContentRootPath = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
123- GXRouting . AzureFunctionName = executionContext . FunctionDefinition . Name ;
124-
125- await _gxRouting . ProcessRestRequest ( httpAzureContextAccessor ) ;
126- return httpResponseData ;
127- }
128111 }
129112
130113}
0 commit comments