Skip to content

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.

License

Notifications You must be signed in to change notification settings

jeffleon1/club_hub

Repository files navigation

Franchise API with GRPC

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.

Structure of this Repo

To build locally

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.

How to make request

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

gRPC

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

Http

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"
    }
}'

Note:

how to install grpcurl

go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published