Skip to content

marekbuild/annotations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

annotations

Example of using grpc-gateway annotations for a simple health check:

service TaskManagementService {
    rpc Health(HealthRequest) returns (HealthResponse) {
        option (google.api.http) = {
            post: "/v1/example/echo"
            body: "*"
        };
    }
}

Build & run

Run the following go commands to build and run the example:

go mod tidy
cd cmd/service
go run service.go
# Output
2023/05/25 14:10:55 Starting service
2023/05/25 14:10:55 Listening http on: 127.0.0.1:8080
2023/05/25 14:10:55 Listening grpc on: 127.0.0.1:9090

Call the service

curl -XPOST "localhost:8080/v1/example/echo" -H "content-type: application/json" -d "{}"
# Output
{"status":"healthy"}

Regenerate protobuf code

The generate protobuf code is already checked into the repo, but if you want to regenerate use the following commands at the base of the repo:

rm -rf gen
buf generate proto --include-imports

About

Example of using grpc-gateway annotations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages