Implementing RESTful endpoints
So far, we have set up the web server using vweb
in the main.v
file. Also, we wrote some commonly used code in util.v
. Now, we will create RESTful endpoints. The endpoints of the microservice we are going to implement will extend the App
struct such that each endpoint will be a method of the App
struct. Additionally, each endpoint we are going to implement returns the response of the vweb.Result
type.
In the following section, we will make a list of all the endpoints we are going to implement inside a file named notes.v
.
The list of RESTful endpoints in our microservice
The microservice we are going to implement will have RESTful endpoints that perform CRUD operations on a database table. The following table shows the endpoints with their corresponding HTTP verb and URL and a description of what the endpoint does along with the request payload, if applicable: