This is a simple CRUD API built using the Go programming language and the Gin web framework. The API allows you to manage tags through basic operations like creating, reading, updating, and deleting.
Click Me
- Clone the repository
- Use docker-compose to run the server
git clone git@github.com:geekyharsh05/gin-rest-api.git
cd gin-rest-api
docker-compose up -d
Click Me
- Clone the repository
- Install the dependencies
- Run the server
git clone git@github.com:geekyharsh05/gin-rest-api.git
cd cd gin-rest-api
go mod tidy
go run main.go
You can use PostgresSQL as the database for this project. To set up the database, follow these steps:
docker run --name postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres:alpine
The following endpoints are available in the application:
- GET /api/tags: Retrieve all tags.
- GET /api/tags/:tagId: Retrieve a tag by ID.
- POST /api/tags: Create a new tag.
- PATCH /api/tags/:tagId: Update an existing tag by ID.
- DELETE /api/tags/:tagId: Delete a tag by ID.
To use the API, you can make HTTP requests to the endpoints. Here's an example of how to create a new tag:
curl --request POST \
--url http://localhost:8888/api/tags \
--header 'Content-Type: application/json' \
--data '{
"name": "Golang"
}
The API also provides a Swagger documentation endpoint. You can access it by making a GET request to the following URL:
http://localhost:8888/docs/index.html
This will display the Swagger documentation page, which includes information about the available endpoints, their parameters, and their responses.
Author Name : Harsh Vardhan Pandey
Author URI : www.aboutharsh.vercel.app
GitHub URI : geekyharsh05