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, browsing http://localhost:8080/employee/get/foo will give us the Hello, followed by the employee name with the status code as 200, as a response in the browser:

On the other hand, accessing http://localhost:8080/employee/get/bar will return us an HTTP error with the message Name Not Found and an error code of 500:

Let's understand the program we have written:

  1. We defined a NameNotFoundError struct with two fields—Code of type int and

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