Skip to content

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.

Notifications You must be signed in to change notification settings

aksh-patel1/go-gin-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:
git clone https://github.com/your-username/go-gin-rest-api.git
  1. Install dependencies:
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:

    go run main.go
  • The API will be accessible at

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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages