Created
January 8, 2017 12:52
-
-
Save gauravrmazra/8b84c82a49b193efe3b6c083d6424045 to your computer and use it in GitHub Desktop.
Pre Spring 4.3 request mapping annotatio example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/api/employees") | |
public class EmployeeController { | |
@RequestMapping | |
public ResponseEntity<List<Employee>> getAll() { | |
return ResponseEntity.ok(Collections.emptyList()); | |
} | |
@RequestMapping("/{employeeId}") | |
public ResponseEntity<Employee> findById(@PathVariable Long employeeId) { | |
return ResponseEntity.ok(EmployeeStub.findById(employeeId)); | |
} | |
@RequestMapping(method = RequestMethod.POST) | |
public ResponseEntity<Employee> addEmployee(@RequestBody Employee employee) { | |
return ResponseEntity.ok(EmployeeStub.addEmployee(employee)); | |
} | |
@RequestMapping(method = RequestMethod.PUT) | |
public ResponseEntity<Employee> updateEmployee(@RequestBody Employee employee) { | |
return ResponseEntity.ok(EmployeeStub.updateEmployee(employee)); | |
} | |
@RequestMapping(path = "/{employeeId}", method = RequestMethod.DELETE) | |
public ResponseEntity<Employee> deleteEmployee(@PathVariable Long employeeId) { | |
return ResponseEntity.ok(EmployeeStub.deleteEmployee(employeeId)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment