go-shopping

command module
v0.0.0-...-ebb3101 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 2 Imported by: 0

README

The project go-shopping is a playground to practice writing an HTTP service in GoLang using gin and gorm.

The project represents a back-end microservice that serves HTTP calls to do basic CRUD (create/read/update/delete) operations on the items in a small magic shop :)

The project was inspired by this article about Gin&Gorm and this article about application layers. The implementation follows official documentation and this article.

Following this article, the application is separated into 3 layers:

  • repositories: interact directly with the database;
  • services: contain the business logic;
  • handlers: accept requests and builds the responses.

Run all tests in the project, but remove the db file first (workaround):

rm -f routers/items.db
go test ./...

If all tests pass, start the HTTP service with:

go run main.go

and the service will run on localhost:8080.

Additionally, in the root of the repository there are following files:

  • Go-Shopping.postman_collection.json - a Postman collection that can be used for reference to send HTTP calls;
  • items.db - a small SQLite Database to start using the project without the need to care about any pre-requisites;
  • items.sql - a backup file containing SQL queries to create an SQLite Database if it does not exist.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL