Local development:
# Run app with migrations
docker compose -f local.yml up
Production:
docker compose -f production.yml up
Integration tests (can be run in CI):
docker compose -f integration_test.yml up --abort-on-container-exit --build --exit-code-from http_v1_integration
Unit tests (can be run in CI):
go test -cover -race $(go list ./... | grep -v /integration_test/)
Generate locale files:
goi18n extract -sourceLanguage=en-US -outdir=./locales/en-US/ -format=yaml ./
Generate docs files:
swag init -g ./internal/controller/http/v1/v1.go -o ./docs/v2
Convert OpenApi v2 to v3 (yaml):
# https://github.com/swaggo/swag/issues/386
docker run --rm -v $(PWD)/docs:/work openapitools/openapi-generator-cli:latest-release \
generate -i /work/v2/swagger.yaml -o /work/v3 -g openapi-yaml --minimal-update \
&& mv ./docs/v3/openapi/openapi.yaml ./docs/v3/ \
&& rm ./docs/v3/README.md \
&& rm ./docs/v3/.openapi-generator-ignore \
&& rm -rf ./docs/v3/.openapi-generator \
&& rm -rf ./docs/v3/openapi
Convert OpenApi v2 to v3 (json):
# https://github.com/swaggo/swag/issues/386
docker run --rm -v $(PWD)/docs:/work openapitools/openapi-generator-cli:latest-release \
generate -i /work/v2/swagger.json -o /work/v3 -g openapi --minimal-update \
&& rm ./docs/v3/README.md \
&& rm ./docs/v3/.openapi-generator-ignore \
&& rm -rf ./docs/v3/.openapi-generator
Change docs.go
package docs
import _ "github.com/TcMits/ent-clean-template/docs/v3" // replace this
// import _ "github.com/TcMits/ent-clean-template/docs/v2"
Iris is an efficient and well-designed, cross-platform, web framework with robust set of features. Build your own high-performance web applications and APIs powered by unlimited potentials and portability.
ent is a simple, yet powerful entity framework for Go, that makes it easy to build and maintain applications with large data-models and sticks with the following principles:
- Easily model database schema as a graph structure.
- Define schema as a programmatic Go code.
- Static typing based on code generation.
- Database queries and graph traversals are easy to write.
- Simple to extend and customize using Go templates.
go-storage is a vendor-neutral storage library for Go.
/api/v1/swagger
Login endpoint
-
URL
/api/v1/login
-
Method:
POST
-
Data Params
{
"username": "string",
"password": "string"
}
-
Success Response:
- Code: 200
Content:
- Code: 200
{
"access_token": "string",
"refresh_token": "string",
"refresh_key": "string"
}
-
Error Response:
- Code:
400
|500
|401
Content:
- Code:
{
"message": "string",
"code": "string"
}
Refresh token endpoint
-
URL
/api/v1/refresh-token
-
Method:
POST
-
Data Params
{
"refresh_token": "string",
"refresh_key": "string"
}
-
Success Response:
- Code: 200
Content:
- Code: 200
{
"token": "string"
}
-
Error Response:
- Code:
400
|500
|401
Content:
- Code:
{
"message": "string",
"code": "string"
}
Verify token endpoint
-
URL
/api/v1/verify-token
-
Method:
POST
-
Data Params
{
"token": "string"
}
-
Success Response:
- Code: 200
Content:
- Code: 200
{}
-
Error Response:
- Code:
400
|500
|401
Content:
- Code:
{
"message": "string",
"code": "string"
}
Me endpoint
-
URL
/api/v1/me
-
Method:
GET
|PUT
|PATCH
-
Data Params
{
"username": "string",
"email": "string",
"first_name": "string",
"last_name": "string"
}
-
Success Response:
- Code: 200
Content:
- Code: 200
{
"self": "string",
"id": "string",
"create_time": "string",
"update_time": "string",
"username": "string",
"first_name": "string",
"last_name": "string",
"email": "string",
"is_staff": "string",
"is_superuser": "string",
"is_active": "string"
}
-
Error Response:
- Code:
400
|500
|401
Content:
- Code:
{
"message": "string",
"code": "string"
}