Skip to content

StockfolioOfficial/django-to-golang-http-api-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-to-golang-http-api-example

Golang HTTP API example like django project

Reference

https://github.com/bxcodec/go-clean-arch

Libs

Database

SQLite

시작방법

  1. Golang 1.7이상 설치
  2. go mod download 터미널에서 실행 (프로젝트 루트에서)
    pip install -r requirements.txtnpm install이랑 같은 맥락
# go mod download all
  1. go run . 터미널에서 실행 (프로젝트 루트에서)
# go run .

빌드 후 실행 방법

  1. #시작방법-1 동일
  2. #시작방법-2 동일
  3. go build -o app . 터미널에서 실행 (프로젝트 루트에서)
    윈도우의 경우 app 이 아니라 app.exe 로 해주세요
# go build -o app .
  1. ./app 터미널에서 실행 (프로젝트 루트에서)
# ./app

API

Article Fetch (List)

목록 가져오기

# curl -X GET http://localhost:8000/articles

Article Create

생성

# curl -X POST -H "Content-Type: application/json" -d "{\"title\":\"제목에 대한 데이터\",\"content\":\"컨텐츠에 대한 데이터\",\"author\":{\"id\":1}}" http://localhost:8000/articles

Article Get (One)

읽기

# curl -X GET http://localhost:8000/articles/{id}

Article Delete

삭제

# curl -X DELETE http://localhost:8000/articles/{id}