Typical REST Server
Example of typical and scalable RESTful API Server for Go
Prerequisite
- Go (It is recommend to install via Homebrew
brew install go)
Build
Use ./typicalw build to build the project.
Use ./typicalw run to build and run the project.
Use ./typicalw test to execute the unit testing.
Learn more about Build Tool
Application
| Name |
Type |
Default |
Required |
| APP_ADDRESS |
string |
:8089 |
Yes |
Modules
Docker
Commands:
./typicalw docker compose: Generate docker-compose.yaml
./typicalw docker up: Spin up docker containers
./typicalw docker down: Take down all docker containers
Server
| Name |
Type |
Default |
Required |
| SERVER_DEBUG |
bool |
false |
|
Postgres
| Name |
Type |
Default |
Required |
| PG_DBNAME |
string |
typical-rest |
Yes |
| PG_USER |
string |
postgres |
Yes |
| PG_PASSWORD |
string |
pgpass |
Yes |
| PG_HOST |
string |
localhost |
|
| PG_PORT |
int |
5432 |
|
Commands:
./typicalw postgres create: Create New Database
./typicalw postgres drop: Drop Database
./typicalw postgres migrate: Migrate Database
./typicalw postgres rollback: Rollback Database
./typicalw postgres seed: Database Seeding
./typicalw postgres console: PostgreSQL Interactive
Redis
| Name |
Type |
Default |
Required |
| REDIS_HOST |
string |
localhost |
Yes |
| REDIS_PORT |
string |
6379 |
Yes |
| REDIS_PASSWORD |
string |
redispass |
|
| REDIS_DB |
int |
0 |
|
| REDIS_POOL_SIZE |
int |
20 |
Yes |
| REDIS_DIAL_TIMEOUT |
Duration |
5s |
Yes |
| REDIS_READ_WRITE_TIMEOUT |
Duration |
3s |
Yes |
| REDIS_IDLE_TIMEOUT |
Duration |
5m |
Yes |
| REDIS_IDLE_CHECK_FREQUENCY |
Duration |
1m |
Yes |
| REDIS_MAX_CONN_AGE |
Duration |
30m |
Yes |
Commands:
./typicalw redis console: Redis Interactive
Release Distribution
Use ./typicalw release to make the release. You can find the binary at release folder.
Learn more Release Distribution