Once we run the program, the HTTP server will start locally listening on port 8080.
Next, executing a DELETE request to delete a BSON document from the command line as follows will give you the name of the document deleted from the database:
$ curl -X DELETE http://localhost:8080/employee/delete?name\=barDocument with name bar is deleted from database
Let’s look at the program we have written:
- We defined a deleteDocument handler, which gets the name to be deleted from MongoDB as the request variable, gets the employee collection from MongoDB, and calls the collection.Remove handler to remove a document for a given name.
- Then, we registered a deleteDocument handler to be called for the URL pattern /employee/delete for every ...