Simple Guestbook API using Gorilla Mux, GORM, and MySQL databases. Simple Go testing, swagger documentation, and client example included.
Check file static/docs/index.html or redoc.html to view API documentation.
Check file static/index.html for example.
Features :
- Pretty simple create & read the post from the database for the guestbook
-
Clone this repository
-
Create the messages table
CREATE TABLE IF NOT EXISTS messages (
id int(5) NOT NULL,
name varchar(50) NOT NULL,
message varchar(160) NOT NULL,
contact varchar(50) NOT NULL,
created_at datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE `messages` ADD PRIMARY KEY (`id`);
ALTER TABLE `messages` MODIFY `id` int(5) NOT NULL AUTO_INCREMENT;
-
Create .env files, check env.example for example.
-
Fix package import
go get
-
Test the code
go test -v
-
Run the code
go run .
-
Build the application
go build .
- Add account system to create, update, and delete the post message using JWT auth
- Arrange file structure.
- Generate the OpenApi document automatically. Currently, I write it manually on swagger.yaml file
- Fix user interfaces for client example, make it more beautiful
- Form validation
MIT