Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aksh-patel1/go-gin-rest-api
This project is a straightforward Go REST API created with the Gin framework and PostgreSQL for player and score management. The API offers various endpoints for performing CRUD operations on player data and obtaining a leaderboard.
https://github.com/aksh-patel1/go-gin-rest-api
gin gin-framework gin-gonic go golang postgres postgresql rest rest-api restful
Last synced: 14 days ago
JSON representation
This project is a straightforward Go REST API created with the Gin framework and PostgreSQL for player and score management. The API offers various endpoints for performing CRUD operations on player data and obtaining a leaderboard.
- Host: GitHub
- URL: https://github.com/aksh-patel1/go-gin-rest-api
- Owner: aksh-patel1
- Created: 2023-12-21T15:46:26.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2023-12-23T15:28:09.000Z (11 months ago)
- Last Synced: 2024-10-15T07:04:42.047Z (about 1 month ago)
- Topics: gin, gin-framework, gin-gonic, go, golang, postgres, postgresql, rest, rest-api, restful
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go REST API with Gin and PostgreSQL
Manage player scores with ease using this lightweight and efficient REST API.
## Features
- CRUD Operations: Create, read, update, and delete player information seamlessly.
- Leaderboard: Retrieve a ranked list of players based on their scores.## Getting Started
### Prerequisites
- Golang (version 1.18 or later)
- PostgreSQL### Installation
1. Clone the repository:
```bash
git clone https://github.com/your-username/go-gin-rest-api.git
```2. Install dependencies:
``` bash
go mod download
```### Database Setup:
- 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)
### Running the API:
- Start the API server:
```bash
go run main.go
```- The API will be accessible at [](http://localhost:8080)
### API Endpoints:
|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.|