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 PUT request from the command line as follows, will update the firstName and the lastName for an employee with ID 1:

$ curl -H "Content-Type: application/json" -X PUT -d '{"Id":"1", "firstName":"Grault", "lastName":"Garply"}' http://localhost:8080/employee/update

 This can be seen in the following screenshot:

If we execute a PUT request for an employee with ID 3 from the command line as follows, it will add another employee to the array, as there is no employee with ID 3, demonstrating the upsert scenario:

$ curl -H "Content-Type: ...

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