Skip to content

Instantly share code, notes, and snippets.

@slmanju
Created January 3, 2018 06:06
Show Gist options
  • Save slmanju/d2990509fae476e0b25f88eba3d56de5 to your computer and use it in GitHub Desktop.
Save slmanju/d2990509fae476e0b25f88eba3d56de5 to your computer and use it in GitHub Desktop.
@RestController
@RequestMapping("/todos")
public class TodoController {
@Autowired
private TodoService todoService;
@GetMapping
public ResponseEntity<?> getAll() {
// list all
}
@GetMapping("/{id}")
public ResponseEntity<?> getById(@PathVariable Long id) {
// get by id (GET)
}
@PostMapping
public ResponseEntity<?> create(@RequestBody TodoDto todoDto) {
// create a todo (POST)
}
@PutMapping("/{id}")
public ResponseEntity<?> update(@PathVariable Long id, @RequestBody TodoDto todoDto) {
// update a todo (PUT)
}
@DeleteMapping("/{id}")
public ResponseEntity<?> delete(@PathVariable Long id) {
// delete a todo (DELETE)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment