Deleting a user 

Find the code snippet for deleteUser() operation as follows:

// to delete a user
@DeleteMapping("/user/{id}")
fun deleteUser(@PathVariable(name = "id")id: Long): ResponseEntity<*>{
userRepository.delete(userRepository.findById(id).get())
return ResponseEntity.ok().build<Any>()
}

The @DeleteMapping("/user/{id}") annotation is the URL path of "/user/{id}" and it is a DELETE request with a specific ID. Here we will delete the specific user details from the database.

If you finish this controller class, then you are ready to run this application and test the REST API using Insomnia.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.223.10