- Just a demo microservice API project using rk_boot
- To learn more about the rk_echo, visit here: https://github.com/rookie-ninja/rk-boot
- git
- golang 1.19
- Install swaggo/swag:
- Run:
go install github.com/swaggo/swag/cmd/swag@latest
- Run:
- Install dependencies:
- Run:
go mod download
- Run:
-
Dev mode:
go run cmd/dev/main.go
-
Prod mode:
go run cmd/prod/main.go
-
Note:
- You may need to run the database and config them first to run the app
- After running the app, you can check out the api docs URLs from the stdout
- Build:
docker build -t rk_echo:latest .
- To build and run the entire stack (rk_echo, mongo, postgres, redis):
- Run:
docker-compose up -d
- Run:
- Run:
go test ./... -cover
- If you encounter some problems with sqlite during running or installation process
- Remove previous installed gcc package (if you use minGW)
- Install this library then restart your machine: https://jmeubank.github.io/tdm-gcc/
- If the issue isn't resolved, run the app in docker
- Run
docker-compose up -d
- Run
cmd
: This contains all the run commands for the appdev/main.go
: run the app in dev mode (auto init swagger before running)prod/main.go
: run the app in prod mode (no swagger init)
docs
: Contains the OpenAPI documentationpkg
: Contains all the pkg, helper modules to build Echo REST APIswaginit
: Contains helper function for generating swagger file automaticallyconn
: Contains helper functions to connect to message queue (kafka, redis)unitest
: Contains helper functions for unit testing
internal
: Contain endpoint and logic for each API. The structure of this module is as follows:handler
: Handle the all the endpoints of the application (take request, get input and pass it to logic layer)repository
: Persistence handlers, all the persistence accees (database, message queue) are handled hereservice
: Logic Layer, all the logic of the service are handled here
boot.yaml
: The boot config contains all the configuration to run rk_boot application. (Configuration as code)