Skip to content

Commit 72eba0c

Browse files
authored
Fix API objects dispatch for azure functions (#490)
* Fix due to changes in Open API issue 91664, issue 92531
1 parent 6567791 commit 72eba0c

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRouting.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,23 +261,36 @@ internal string GetGxRouteValue(string path)
261261
{
262262
//Not API Objects
263263
string basePath = restBaseURL;
264+
string pathWithNoBase = string.IsNullOrEmpty(basePath) ? path.Substring(1) : path.Substring(basePath.Length + 2);
264265

265266
//API Objects
267+
string AzureFunctionShortName = AzureFunctionName.Substring(AzureFunctionName.LastIndexOf(".") + 1);
268+
string controllerWithParms = "";
266269
foreach (var map in servicesMap)
267270
{
268-
foreach (var mlist in map.Value)
271+
if (path.ToLower().Contains(map.Key.ToLower()))
269272
{
270-
if (mlist.Key == AzureFunctionName)
273+
foreach (var mlist in map.Value)
271274
{
272-
basePath = string.IsNullOrEmpty(restBaseURL) ? $"{map.Key}" :$"{restBaseURL}/{map.Key}";
275+
if (mlist.Key.ToLower() == AzureFunctionShortName.ToLower())
276+
{
277+
278+
controllerWithParms = mlist.Value.Path;
279+
if (pathWithNoBase.ToLower().EndsWith(controllerWithParms.ToLower()))
280+
{
281+
if (pathWithNoBase.Remove(pathWithNoBase.Length - controllerWithParms.Length).ToLower() == map.Key.ToLower())
282+
return controllerWithParms;
283+
}
284+
}
273285
}
274286
}
275287
}
276288

277-
string controllerWithParms = path.Remove(0, basePath.Length + 1);
289+
controllerWithParms = path.Remove(0, basePath.Length + 1);
278290
controllerWithParms = controllerWithParms.StartsWith("/") ? controllerWithParms.Remove(0, 1) : controllerWithParms;
279291
return controllerWithParms;
280-
292+
293+
281294
}
282295
public bool ServiceInPath(String path, out String actualPath)
283296
{

dotnet/src/extensions/Azure/Handlers/GeneXus.Deploy.AzureFunctions.Handlers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
44
<OutputType>Exe</OutputType>

0 commit comments

Comments
 (0)