Skip to content

Commit 9f2f486

Browse files
committed
Bael-6477, Spring Cloud Function for Azure Function
1 parent 83d80e3 commit 9f2f486

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

spring-cloud-modules/spring-cloud-functions-azure/src/main/java/com/baeldung/azure/functions/EmployeeSalaryFunctionWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Function<Employee, Employee> getCityBasedSalaryFunction(Employee employee
1919
Function<Employee, Employee> salaryCalculatorFunction;
2020
switch (employee.getCity()) {
2121
case "Chicago" -> salaryCalculatorFunction = functionCatalog.lookup("chicagoSalaryCalculatorFn");
22-
case "California" -> salaryCalculatorFunction = functionCatalog.lookup("californiaSalaryCalculatorFn");
22+
case "California" -> salaryCalculatorFunction = functionCatalog.lookup("californiaSalaryCalculatorFn|defaultSalaryCalculatorFn");
2323
case "New York" -> salaryCalculatorFunction = functionCatalog.lookup("newYorkSalaryCalculatorFn");
2424
default -> salaryCalculatorFunction = functionCatalog.lookup("defaultSalaryCalculatorFn");
2525
}

spring-cloud-modules/spring-cloud-functions-azure/src/main/java/com/baeldung/azure/functions/EmployeeSalaryHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ public HttpResponseMessage calculateSalaryWithSCF(
5454
Employee employeeRequest = employeeHttpRequestMessage.getBody().get();
5555
executionContext.getLogger().info("Salary of " + employeeRequest.getName() + " is:" + employeeRequest.getSalary());
5656
EmployeeSalaryFunctionWrapper employeeSalaryFunctionWrapper = new EmployeeSalaryFunctionWrapper(functionCatalog);
57-
58-
Employee employee = employeeSalaryFunctionWrapper.getCityBasedSalaryFunction(employeeRequest).apply(employeeRequest);
57+
Function<Employee, Employee> cityBasedSalaryFunction = employeeSalaryFunctionWrapper.getCityBasedSalaryFunction(employeeRequest);
58+
executionContext.getLogger().info("The class of the cityBasedSalaryFunction:" + cityBasedSalaryFunction.getClass());
59+
Employee employee = cityBasedSalaryFunction.apply(employeeRequest);
5960
executionContext.getLogger().info("Final salary of " + employee.getName() + " is:" + employee.getSalary());
6061
return employeeHttpRequestMessage.createResponseBuilder(HttpStatus.OK)
6162
.body(employee)

0 commit comments

Comments
 (0)