This project is still in development, and I will add more features in the future. It is made by following CLean Architecture rules by Uncle Bob, and I also added some of my own rules to make it more readable and maintainable. This is written in Golang, and I used Echo Framework as the web framework, and MySQL as the database. I also added some middlewares to make it more secure and more readable. I also added some unit tests to make sure that the code is working as expected.
- Clone this repository
- Create a database named
books.sql
in your MySQL database [Name is changeable] - Import the
books.sql
file in the database - Change the database configuration in
config.json
file - Run the project using
go run main.go
or refer to Makefile for more commands
GET /books
curl -i -H 'Accept: application/json' http://localhost:8080/books
HTTP/1.1 200 OK
Date: Sun, 20 Jun 2021 15:00:00 GMT
Content-Type: application/json
Content-Length: 2
[
{
"id": 1,
"title": "Book Title",
"author": "Book Author"
}
]
GET /books/:id
curl -i -H 'Accept: application/json' http://localhost:8080/books/1
HTTP/1.1 200 OK
Date: Sun, 20 Jun 2021 15:00:00 GMT
Content-Type: application/json
Content-Length: 2
[]
POST /books
curl -i -H 'Accept: application/json' -d 'title=Book Title&author=Book Author' http://localhost:8080/books
HTTP/1.1 201 Created
Date: Sun, 20 Jun 2021 15:00:00 GMT
Content-Type: application/json
Content-Length: 2
[
{
"id": 1,
"title": "Book Title",
"author": "Book Author"
}
]
PUT /books/:id
curl -i -H 'Accept: application/json' -d 'title=Book Title&author=Book Author' http://localhost:8080/books/1
HTTP/1.1 200 OK
Date: Sun, 20 Jun 2021 15:00:00 GMT
Content-Type: application/json
Content-Length: 2
[
{
"id": 1,
"title": "Book Title",
"author": "Book Author"
}
]
DELETE /books/:id
curl -i -H 'Accept: application/json' -X DELETE http://localhost:8080/books/1
HTTP/1.1 204 No Content
Date: Sun, 20 Jun 2021 15:00:00 GMT
MIT
[Huzaifa M.]