The program needs dep to download all the packages needed in the code
- Compile the code using this command
go build -o [binary name]
- Run program
./[binary name] <command> [argumnets]
- a.the coomands are:
gt
generates an empty .yaml templategs
generates a service from a .yaml file
- The yaml file should contain the name of the service.
- The yaml file should contain at least one endpoint inorder to generate the code
- The transport method and path should be provided for each and every endpoint in order to generate the code.
- Model is optional.
- Caching layer is optional.
- Transport file that contains all the code needed inroder to have a rest api
- Encoders file that is needed to help the transport layer to decode and encode the informations
- Service file that contains all the code needed to run the service
- Server file that contains the Serve function that need to be called to run the program
- model file that contains everything specifed in the model section of the yaml file ( it has setters and getters)
- Endpoint file that contains all the endpoints specified in the yaml file
- Repository can be generated and connected to a database.
- The supported databases are mysql and postgress
- Caching layer using redis can be generated to cash all Get requests for a specified amount of time
The option to create and run the service in a Docker container will be added.
name: userService
redis_cache:
host: host
password: password
db: 0
endpoints:
-
name: CreateUser
args:
- user User
output:
- id string
transport:
method: POST
path: /user
-
name: GetUser
args:
- id string
output:
- user User
cache_time: 10000
transport:
method: GET
path: /user/{id}
-
name: UpdateUser
args:
- id string
- profilePic string
output:
- message string
transport:
method: PUT
path: /user/update
-
name: GetAllUsers
args:
output:
- users []User
cache_time: 10000
transport:
method: GET
path: /user
repository:
value: true
db:
name: mysql
address: address
model:
-
name: User
attr:
- firstName string
- lastName string
- profilePic string
- token string