Performance: @PutMapping and @DeleteMapping
MEDIUM IMPACT
These annotations affect server request handling speed and network payload size, impacting how fast the client sees updates or deletions.
@PutMapping("/resource/{id}") public ResponseEntity<?> updateResource(@PathVariable Long id, @RequestBody Resource resource) { // update logic return ResponseEntity.ok().build(); } @DeleteMapping("/resource/{id}") public ResponseEntity<?> deleteResource(@PathVariable Long id) { // delete logic return ResponseEntity.noContent().build(); }
@PostMapping("/updateResource") public ResponseEntity<?> updateResource(@RequestBody Resource resource) { // update logic return ResponseEntity.ok().build(); } @PostMapping("/deleteResource") public ResponseEntity<?> deleteResource(@RequestParam Long id) { // delete logic return ResponseEntity.ok().build(); }
| Pattern | Server Processing | Network Overhead | Caching Impact | Verdict |
|---|---|---|---|---|
| Using @PostMapping for update/delete | Standard processing | Higher due to unclear intent | Poor caching, more revalidation | [X] Bad |
| Using @PutMapping and @DeleteMapping correctly | Optimized for intent | Lower due to proper semantics | Better caching, less revalidation | [OK] Good |