|
|
||
|---|---|---|
| .. | ||
| build | ||
| cmd | ||
| config | ||
| etc | ||
| example | ||
| grpc | ||
| internal | ||
| rest | ||
| vendor | ||
| CHANGELOG.md | ||
| Gopkg.lock | ||
| Gopkg.toml | ||
| Makefile | ||
| README.md | ||
| package.yml | ||
README.md
companies-service
Description
Service for exposing company related operations. This service can be consumed using grpc or rest.
Source code folders
/cmd/companies-service-grpc- contains the main.go for gRPC service/cmd/companies-service-rest- contains the main.go for REST service/config- contains the default configuration/example- contains code examples to build a client/errors- contains error definitions/etc- contains example configuration files/grpc- contains proto defintions/internal/companies- contains the business logic/internal/domain-/internal/storage-/internal/storage/gorm-/rest- contains a swagger file/rest/models- generated by Swagger/rest/server- generated by Swagger/rest/client- generated by Swagger/vendor-
Compiling and installing
Generate REST server and client using generate.go
cd rest; go generate; cd ..
Build and install go application
go install ./...
Running the application
Run this service with the --config flag to point to the appropriate configuration file, i.e.
companies-service-grpc --config=./etc/companies-service_test.conf
companies-service-rest --config=./etc/companies-service_test.conf
Testing the application
More debugging output for swagger
If you want to debug what the client is sending and receiving you can set the environment value DEBUG to a non-empty value
(i.e. in Linux use: export DEBUG=1 or unset DEBUG)
Go Unit test
cd internal/companies/; go test; cd ../..
Using cURL on the REST API
Get info on company ID 1
curl -XGET -H "Content-Type: application/json" -H "Authorization: [token]" -w "\n" https://api.mtinfo3000.com/companies-service/v1/companies/1
Use the client example
cd example; go test -v; cd ..