March 2019
Beginner to intermediate
324 pages
7h 17m
English
The next logical step in building our RESTful API is to define the actions that we need to perform when we receive client requests. This is also known as building handlers. So, let's start.
In the backend/src/rest folder, create a new file called handler.go. In this file, we'll write the code that is needed to handle the actions that correspond to the different API requests that our server is expected to receive.
As always, the first thing we need to do is to declare the package and import the external packages that we need to use, as follows:
package restimport ( "fmt" "log" "net/http" "strconv" "github.com/PacktPublishing/Hands-On-Full-Stack-Development-with-Go/Chapter06/backend/src/dblayer" "github.com/PacktPublishing/Hands-On-Full-Stack-Development-with-Go/Chapter06/backend/src/models" ...
Read now
Unlock full access