add another defaultpathvariable method

This commit is contained in:
karan 2020-07-24 01:08:45 -04:00
parent 6ced667bd5
commit c4770ac40f

View File

@ -66,6 +66,16 @@ public class PathVariableAnnotationController {
}
}
@GetMapping(value = { "/api/defaultemployeeswithoptional", "/api/defaultemployeeswithoptional/{id}" })
@ResponseBody
public String getDefaultEmployeesByIdWithOptional(@PathVariable Optional<String> id) {
if (id.isPresent()) {
return "ID: " + id.get();
} else {
return "ID: Default Employee";
}
}
@GetMapping(value = { "/api/employeeswithmap/{id}", "/api/employeeswithmap" })
@ResponseBody
public String getEmployeesByIdWithMap(@PathVariable Map<String, String> pathVarsMap) {