sample

command module
v0.0.0-...-54ab06f Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Sample Project

REST API sample used sqlw

The samaple app has three apis below

Running the sample app

  1. Executes docker-compose command to launch mysql
  2. Run the go command to launch sample app
$ cd mysql
$ docker-compose up -d
$ cd ../sample
$ go run main.go

Layer and package structure of the sample app

Sample app has three layers like port, usecase, domain.

  • port
    • includes http request handlers and more
  • usecase
    • includes business logics
  • domain
    • includes domain models
main.go
├─ port
│  ├─ handler
│  └─ repository(implementation)
├─ usecase
│  ├─ interactor
│  └─ repository(interface)
└─ domain
   └─ model

Each layers dependency is below

port -> usecase -> domain

API Specifications

Get all items

http://localhost:8080/items

HTTP Method

GET

URL Params

None

Response
[
  {
    "id": "48c0c6c2-268c-11eb-850f-acde48001122",
    "name": "bar"
  },
  {
    "id": "4c3e0fda-268c-11eb-850f-acde48001122",
    "name": "foo"
  }
]
Get an item

http://localhost:8080/items/{item_id}

HTTP Method

GET

URL Params

item_id string

Response
{
  "id": "48c0c6c2-268c-11eb-850f-acde48001122",
  "name": "bar"
}
Create an item

http://localhost:8080/items

HTTP Method

POST

Request Body

name string

Response
{
  "id": "48c0c6c2-268c-11eb-850f-acde48001122",
  "name": "baz"
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
domain
port
usecase

Jump to

Keyboard shortcuts

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