O'Reilly logo

Go Web Development Cookbook by Arpit Aggarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works…

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:

  1. 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.
  2. Then, we registered a deleteDocument handler to be called for the URL pattern /employee/delete for every ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required