Skip to content

LYSingD/simple-go-games-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple rest api with Golang

A simple REST API for self-practice. Inspired by kubucation YouTube channel (link)

Tech Stack

  • Golang

Data type

There is only one object called game contain the following default data:

type Game struct {
	ID        string   `json:"id"`
	Name      string   `json:"name"`
	Developer string   `json:"developer"`
	Rating    string   `json:"rating"`
	Genres    []string `json:"genres"`
}

[
    {
	ID:        "816d17bb-c943-4b8c-ba8a-54e0429985c7",
	Name:      "Ghost of Tsushima",
	Developer: "Sucker Punch",
	Rating:    "M",
	Genres:    []string{"General", "Action Adventure", "Open-World"},
    },
    {
	ID:        "ee9015a7-6219-4620-af98-cf78601c6446",
	Name:      "Monster Hunter World: Iceborne",
	Developer: "Capcom",
	Rating:    "T",
	Genres:    []string{"Action"},
    },
    {
	ID:        "c2b337b0-839f-40b8-b43d-921bfd2812a8",
	Name:      "Watch Dog",
	Developer: "Ubisoft",
	Rating:    "M",
	Genres:    []string{"Action", "Adventure"},
    }
]

Run Locally

Clone the project

  git clone https://github.com/LYSingD/go-games-rest-api.git

Go to the project directory

  cd [path]/go-games-rest-api/

Configure the desired port in /server.go, line 14.

log.Fatal(http.ListenAndServe(":[port]", nil))

Run the server

  go run server.go

Use curl command, like

  curl localhost:8080/games

API endpoints

/games

  • GET - Get a list of all games, returned as JSON
  • POST - Add a new game from request data sent as JSON

/games/:id

  • GET - Get a specific game by its ID, return the data as JSON
  • PUT - Update a specific game by its ID from request data sent as JSON
  • DELETE - Delete a specific game by its ID

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages