This is a sample RESTful API project built using Golang, featuring book categories and user entities. The application supports CRUD operations for managing categories, users, and books. The project is dockerized and utilizes PostgreSQL as its database.
To get started with this project, follow the steps below:
-
Clone the repository:
git clone https://github.com/your-username/rest_api_sample.git cd rest_api_sample
-
Set up your database: PostgreSQL database and update the database configuration in the config/config.go file.
-
Dockerize the API:
docker build -t my-api
-
Compose up the docker-compose.yml
docker-compose up -d
- GET /category: Retrieve all categories.
- GET /category/{id}: Retrieve a specific category by ID.
- POST /category: Create a new category.
- PUT /category/{id}: Update a category by ID.
- DELETE /category/{id}: Delete a category by ID.
- GET /user: Retrieve all users.
- GET /user/{id}: Retrieve a specific user by ID.
- POST /user: Create a new user.
- PUT /user/{id}: Update a user by ID.
- DELETE /user/{id}: Delete a user by ID.
- GET /book: Retrieve all books.
- GET /book/{id}: Retrieve a specific book by ID.
- POST /book: Create a new book.
- PUT /book/{id}: Update a book by ID.
- DELETE /book/{id}: Delete a book by ID.
The API documentation is available using Swagger. Visit /swagger/index.html
after running the application to explore and interact with the API.
The application will be accessible at localhost.
This project is licensed under the MIT License.