REST API for a shoe store using Go and Gin Web Framework

Overview

REST API for a shoe store using Go and Gin Web Framework

This API uses a local PostgreSQL database that's set through the /gopostgres/driverConfig.go file.

To run the project

Once you are in the /main folder run the command:

$ go run main.go

To get all the dependencies

  • Gin Web Framework:
$ go get -u github.com/gin-gonic/gin
  • Go Postgres driver:
$ go get github.com/lib/pq

Packages

  • package main: database initialization the call for GET, POST, PUT and DELETE functions.
  • package shoe: data model for a shoe and the functions to get, add, update or delete it from the database.
  • package dbconfig: database parameters that will be used on it's initialization.
  • package handler: functions that will use Gin Web Framework to handle JSON activities.

API Authentication

GetAll Request

  • GET localhost:8080/get: gets all shoes from the database.
  • Response example:
[
	{
		"id": 1,
		"name": "Shoe 1",
		"style": "Style 1",
		"colour": "Colour 1",
		"material": "Material 1",
		"price": 1
	},
	{
		"id": 2,
		"name": "Shoe 2",
		"style": "Style 2",
		"colour": "Colour 2",
		"material": "Material 2",
		"price": 2
	}
]

GetShoe Request

  • GET localhost:8080/:id: gets a specific shoe from the database using the ID.
  • Response example:
{
	"id": 1,
	"name": "Shoe 1",
	"style": "Style 1",
	"colour": "Colour 1",
	"material": "Material 1",
	"price": 1
}

AddShoe Request

  • POST localhost:8080/post: adds a shoe to the database passing the parameters through the body.
  • Body example:
{
	"name":"Shoe 1",
	"style":"Style 1",
	"colour":"Colour 1",
	"material":"Material 1",
	"price":"1"
}

UpdateShoe Request

  • PUT localhost:8080/put: updates a shoe from the database with the ID equal to the one passed on the body.
  • Body example:
{
	"id":"1",
	"name":"Shoe 1 updated",
	"style":"Style 1 updated",
	"colour":"Color 1 updated",
	"material":"Material 1 updated",
	"price":"1.1"
}

DeleteShoe Request

  • DELETE localhost:8080/:id: deletes a specific shoe from the database using the ID.

You might also like...
Using golang framework (Gin) to create a web-application

News feeder Using golang framework (Gin) to create a web-application. This simpl

Gin-easy-todo - golang 의 RESTful API 프레임워크 gin 을 활용해 아주 간단한 Todo 애플리케이션을 만들어보자.
Gin-easy-todo - golang 의 RESTful API 프레임워크 gin 을 활용해 아주 간단한 Todo 애플리케이션을 만들어보자.

목차 1. 요약 2. 목표 3. API 목록 4. 프로젝트 구조 5. 패키지 별 기능과 관계 6. 사전 작업 6.1. DB, Table 생성 6.2. 모듈 생성 6.3. 패키지 다운로드 7. Gin 작성 7.1. 데이터베이스 설정 7.2. 테이블, 스키마 정의 7.3.

Restful API example with using go and gin framework

simple device api Simple Device API is really simple and concise to show how easy to implement a Restful Service with using Golang. It uses gin framew

Built a causally consistent, replicated and sharded key value store with a REST API.

A causally consistent, replicated and sharded key value store built in Golang with a RESTful API. Runs through the use of a Docker container.

A fully-featured REST API developed in Golang for an online book store.

A fully-featured REST API developed in Golang for an online book store.

A fully-featured REST API developed in Golang for an online book store.

E-book Store A fully-featured REST API developed in Golang for an online book store. API Documentation Features Authentication (Sign up, Login and Res

REST-API specifically build to support online store system of Zahir
REST-API specifically build to support online store system of Zahir

Rest Test. • From Above ERD please create Rest full API. Create register API(Include Generate password). • Acceptance o Phone number and email is uniq

ging is a tool for create gin web framework development templates

ging ging is a tool for create gin web framework development templates This tool is for the freshmen who want to learn golang and gin web framework, i

Demo application to implement a REST api backend service for an android app using the Go aah framework.

aah-recycleview-backend This tutorial is based on the aah framework to implement a REST API form of CRUD application services, taking "IN-MEMORY" stor

Owner
Nalbert Wattam
Backend developer, mainly working with Golang (Gin Web Framework).
Nalbert Wattam
Gin-boilerplate - This repository contains boilerplate code of a REST service using Gin (golang) framework.

Boilerplate REST service using Gin web framework (golang) Introduction This repository contains a boilerplate REST API service using Gin web framework

null 6 Apr 28, 2022
Gin-errorhandling - Gin Error Handling Middleware is a middleware for the popular Gin framework

Gin Error Handling Middleware Gin Error Handling Middleware is a middleware for

Joseph Woodward 9 Sep 19, 2022
Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM

GOLANG API REST Clean api rest with Go, Gin and GORM. Clean Architecture with DD

Juan Cantón Rodríguez 17 Oct 21, 2022
Gin-boilerplate - Gin boilerplate preconfigured with basic rest api features

Gin Boilerplate Build apis with gin faster with this template Features Validatio

Mohan barman 4 Jun 24, 2022
Go-gin-mongo-api - A backend RESTful API built using golang, gin and mongoDB

go-gin-mongo-API This is a RESTful backend API which is developed using the gola

Humbe Jeffrey 6 Jul 19, 2022
Go-service-gin - Simple Web api application developed in Golang and Gin

Simple Web api application developed in Golang and Gin Initial Tutorial URL http

Nurul Huda Robin 0 Jan 4, 2022
GinGoExample - Implement rest api using gin and go and mongodb

GinGoExample Implement rest api using gin and go and mongodb Optimizations using Singlton pattern to avoid repetetive commiunication with mongodb . Fe

Mehdi 0 Mar 25, 2022
Dating-server - Go (Golang) API REST Template/Boilerplate with Gin Framework

go-rest-template Go (Golang) API REST Template/Boilerplate with Gin Framework 1.

null 1 Apr 3, 2022
GoCondor is a golang web framework with an MVC like architecture, it's based on Gin framework

GoCondor is a golang web framework with an MVC like architecture, it's based on Gin framework, it features a simple organized directory structure for your next project with a pleasant development experience, made for developing modern APIs and microservices.

Go Condor 38 Dec 29, 2022
Simple web app using Go and Gin framework

go-gin-app Simple web app using Go and Gin framework Golang 과 Gin 프레임워크를 사용한 간단한 웹 앱 How to get Started Install Gin and have Go installed on your syst

Sean Hong(홍성민) 0 Oct 18, 2021