TODO app with onion architecture.
use sqlite3.
go get github.com/mattn/go-sqlite3
use echo.
go get github.com/labstack/echo/v4
request
curl -X POST http://localhost:8080/1/todos -H "Content-Type: application/json" -d '{"title":"test","description":"test"}'
response
{
"id": 9
}
request
curl -X GET http://localhost:8080/1/todos
response
{
"todos": [
{
"id": 6,
"title": "test",
"description": "test",
"created_at": "2023-05-20T07:46:49.112686+09:00",
"delete_at": "0001-01-01T00:00:00Z"
},
{
"id": 7,
"title": "test",
"description": "test",
"created_at": "2023-05-21T14:58:50.918357+09:00",
"delete_at": "0001-01-01T00:00:00Z"
},
{
"id": 8,
"title": "test",
"description": "test",
"created_at": "2023-05-21T17:31:32.128915+09:00",
"delete_at": "0001-01-01T00:00:00Z"
},
{
"id": 9,
"title": "test",
"description": "test",
"created_at": "2023-05-21T17:31:45.145144+09:00",
"delete_at": "0001-01-01T00:00:00Z"
}
]
}
request
curl -X DELETE localhost:8080/todos/9
response
HTTP/1.1 204 No Content
request
curl -X POST http://localhost:8080/users -H "Content-Type: application/json" -d '{"name":"yamanaka"}'
response
{
"id": 2
}
request
curl -X GET http://localhost:8080/user/2
response
{
"user": {
"id": 2,
"name": "yamanaka",
"created_at": "2023-05-21T17:39:00.358339+09:00"
}
}
go get github.com/stretchr/testify
go get github.com/golang/mock/gomock
create mock
go generate ./...
go get -u github.com/ory/dockertest/v3
but, this sample use sqlite3. so, not use dockertest.
go get -u github.com/sebdah/goldie/v2