Manage player scores with ease using this lightweight and efficient REST API.
- CRUD Operations: Create, read, update, and delete player information seamlessly.
- Leaderboard: Retrieve a ranked list of players based on their scores.
- Golang (version 1.18 or later)
- PostgreSQL
- Clone the repository:
git clone https://github.com/your-username/go-gin-rest-api.git
- Install dependencies:
go mod download
- Create a PostgreSQL database named gamedatabase
- Create a table named players with the following columns:
- player_id (integer, primary key)
- player_name (text)
- score (integer)
Endpoints | Method | Description |
---|---|---|
/player | GET | Retrieve information about all players. |
/player | POST | Add a new player with score information. |
/player/{id} | DELETE | Delete a player by their ID. |
/player/{id} | PATCH | Update player information: name, score, or both. |
/leaderboard | GET | Retrieve the player leaderboard sorted by score. |