src.dualinventive.com/go/companies-service
Jerry Jacobs 1193c82181 initial 2024-08-09 12:10:16 +02:00
..
build initial 2024-08-09 12:10:16 +02:00
cmd initial 2024-08-09 12:10:16 +02:00
config initial 2024-08-09 12:10:16 +02:00
etc initial 2024-08-09 12:10:16 +02:00
example initial 2024-08-09 12:10:16 +02:00
grpc initial 2024-08-09 12:10:16 +02:00
internal initial 2024-08-09 12:10:16 +02:00
rest initial 2024-08-09 12:10:16 +02:00
vendor initial 2024-08-09 12:10:16 +02:00
CHANGELOG.md initial 2024-08-09 12:10:16 +02:00
Gopkg.lock initial 2024-08-09 12:10:16 +02:00
Gopkg.toml initial 2024-08-09 12:10:16 +02:00
Makefile initial 2024-08-09 12:10:16 +02:00
README.md initial 2024-08-09 12:10:16 +02:00
package.yml initial 2024-08-09 12:10:16 +02:00

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 ..