This is a project demonstrating RESTful API using the Go programming language with the Gin web framework and GORM for database interactions.
- Go installed on your machine
- Mysql RDBMS installed on your machine
- npm http-server installed globally in your machine
-
Clone the repository :
git clone https://github.com/Abyanzhafran/candle.git
git checkout backend-experimental
cd backend
-
run this for synchronize the package :
go mod tidy
-
Configure the database:
- Config you database setting like
.env.example
file.
- Config you database setting like
-
Run the application:
go run main.go
-
Run file storage server:
http-server -p 8081
-
The Go API will be available at
http://localhost:8080
.
- For detailed api endpoint, look at api-spec.yml file, and run it using swagger editor.
- It can CRUD book entity based on provided endpoint on apis-spec.yml
- The user entity have Ge tAllUsers, GetUserByUsername, and UserLogin api endpoint.
- There are an image_data folder and uploaded_image folder.
- The image_data folder is just the example book images that you can use for updating the book.
- The uploaded_image folder, is used to visualize online file storage, so the added book cover, saved at that folder. It also applies to CRUD method for the images.
- When you try to update the book data in postman using PUT method and for example you don't want to update the image file, then don't include the image file as form-data, and keep the "imageurl" field the same as related image file in database.
- When you try to update the book data in postman using PUT method and for example you want to update the image file also, then include the image file and make the "imageurl" field as empty string like this "".