Go gRPC server for demonstrating unary gRPC requests
go build -o go-grpc-tc
go run main.go
go test ./user
Use a gRPC client tool like POSTMAN and upload the proto file
Important
After uploading the proto file Set url to "localhost:8080" and select appropriate service from dropdown at the right
Example screenshots are attahced
Note
On starting the server two users are seeded by default into the databases, they are as follows :
1: {ID: 1, FName: "John", City: "New York", Phone: 1234567890, Height: 180.5, Married: true}
2: {ID: 2, FName: "Jane", City: "Los Angeles", Phone: 9876543210, Height: 165.2, Married: false}
type User struct {
ID UserId
FName string
City string
Phone int64
Height float64
Married bool
}
{
"id": 1
}
{
"user": {
"id": 1,
"fname": "John",
"city": "New York",
"phone": "1234567890",
"height": 180.5,
"married": true
}
}
{
"id": 0
}
{
Invalid argument
You have specified an invalid argument.
}
{
"ids": [2, 45]
}
{
"users": [
{
"id": 2,
"fname": "Jane",
"city": "Los Angeles",
"phone": "9876543210",
"height": 165.2,
"married": false
},
{
"id": 45,
"fname": "reprehenderit consectetur exercitation velit Ut",
"city": "Lorem aliqua",
"phone": "8442039398",
"height": 48909313.409837335,
"married": false
}
]
}
{
"fname": "Jane"
}
{
"users": [
{
"id": 2,
"fname": "Jane",
"city": "Los Angeles",
"phone": "9876543210",
"height": 165.2,
"married": false
}
]
}
{
"city": "New York"
}
{
"users": [
{
"id": 1,
"fname": "John",
"city": "New York",
"phone": "1234567890",
"height": 180.5,
"married": true
}
]
}
{
"phone": "8442039398"
}
{
"users": [
{
"id": 45,
"fname": "reprehenderit consectetur exercitation velit Ut",
"city": "Lorem aliqua",
"phone": "8442039398",
"height": 48909313.409837335,
"married": false
}
]
}
{
"married": false,
"searchmarried": true
}
{
"users": [
{
"id": 2,
"fname": "Jane",
"city": "Los Angeles",
"phone": "9876543210",
"height": 165.2,
"married": false
},
{
"id": 45,
"fname": "reprehenderit consectetur exercitation velit Ut",
"city": "Lorem aliqua",
"phone": "8442039398",
"height": 48909313.409837335,
"married": false
}
]
}
{
"city": "Lorem aliqua",
"fname": "reprehenderit consectetur exercitation velit Ut",
"height": 48909313.409837335,
"id": 45,
"married": false,
"phone": "8442039398"
}
{
"user": {
"id": 45,
"fname": "reprehenderit consectetur exercitation velit Ut",
"city": "Lorem aliqua",
"phone": "8442039398",
"height": 48909313.409837335,
"married": false
}
}
{
}
{
Invalid argument
You have specified an invalid argument.
}
Note
By default page is set to 1 and and pageSize is 10 (i.e. if request body is empty )
{
"page": 1,
"pageSize": 1
}
{
"users": [
{
"id": 2,
"fname": "Jane",
"city": "Los Angeles",
"phone": "9876543210",
"height": 165.2,
"married": false
}
]
}