Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 26 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.

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.|