Description
In this course, you will :
- Create a model from Golang's struct type and a slice to add records to
- Create a router and register to it api endpoints and handler functions
- Build handler functions to do CRUD operations
- Create a Postgres database instance and a table to save records
- Establish a connection to the database and query the table for records as well as insert, update and delete individual records
- Build the handler functions to make queries to the database and perform CRUD operations on persistent data
- Make use of packages such as gorilla/mux, strconv, reflect and etc
Syllabus :
1. REST, creating the model and registering the routes
- Introduction to REST
- Create the Book model and books slice
- Install third party packages
- Create the router and register api-endpoints and handler
2. Implementing CRUD apis with data in memory
- Add static data and implement 'getBooks'
- Implement 'getBook' handler to get a single book
- Implement 'addBook' and use Postman for http requests
- Implement 'updateBook'
- Implement 'removeBook'
3. Persisting the data
- Refactor code to include database interaction
- Set and load environment variables
- Connect to the database instance
- Implement 'getBooks' to get all book records from the table
- Implement 'getBook' to get a book record from the table by its id
- Implement 'addBook' to add a book record to the table
- Implement 'updateBook' to update a book record on the table
- Implement 'removeBook' to remove a book record from the table by its id
4. Refactor
- Go modules
- Create book and error models
- Refactor driver and book model
- Create utils methods
- Create Getbooks Controller method
- Create GetBooks Repository method
- Refactor the GetBook handler
- Refactor addBook, updateBook and removeBook handlers