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 from the command line to delete an employee with the name as bar will give you the number of records deleted from the database:

$ curl -X DELETE http://localhost:8080/employee/delete?name\=barNumber of rows deleted in database are :: 1

Let’s look at the program we have written:

  1. We defined a deleteRecord handler, which gets the name to be deleted from the database as the request variable, prepares a DELETE statement with a name as a placeholder, which will be replaced dynamically, executes the statement, gets the count of rows deleted as a result of its execution, and writes it to an HTTP response stream.
  2. Next, ...

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