This is a small application for the management of franchises created with grpc that has two microservices, one for the management of the metadata of the franchises and the other in charge of the most revealing attributes of the franchise such as where it is located, website, name, etc.
This application has the particularity that thanks to grpc-gateway it is also exposed in http which allows to make requests through both protocols.
- Proto files: https://github.com/jeffleon1/club_hub/blob/main/api/franchise.proto
- Franchise microservice: https://github.com/jeffleon1/club_hub/tree/main/franchise
- Metadata microservice: https://github.com/jeffleon1/club_hub/tree/main/metadata
- Go api build: https://github.com/jeffleon1/club_hub/blob/main/Makefile
You need a machine (linux) that has Go installed > 1.19 and make, you also need to change the .env-sample
file to .env
once you have done this you can run make up_build
.
these are the two postman collections to test for gRPC and Http
also if you have grpcurl or curl you can use it here are some examples of how to test the application
grpcurl -plaintext -d '{"host":"marriot.com"}' localhost:8080 FranchiseService/CreateFranchise
grpcurl -plaintext -d '{"company_id":0}' localhost:8080 FranchiseService/GetFranchise
grpcurl -plaintext -d '{"franchise":{"name":"hilton"}, "id":1}' localhost:8080 FranchiseService/UpdateFranchise
grpcurl -plaintext -d '{"key":"url", "value":"marriott.com"}' localhost:8080 FranchiseService/GetFranchiseByFilter
curl --location 'localhost:8090/v1/franchises' \
--header 'Content-Type: application/json' \
--data '{
"host": "marriot.com"
}'
curl --location 'localhost:8090/v1/franchise?company_id=0'
curl --location 'localhost:8090/v1/franchise?key=name&value=marriot'
curl --location --request PUT 'localhost:8090/v1/franchise/1' \
--header 'Content-Type: application/json' \
--data '{
"franchise": {
"name":"hilton"
}
}'
how to install grpcurl
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest