init
This commit is contained in:
parent
e0cee7bdd4
commit
1ced5eb275
|
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
helloworld "github.com/helloworlde/grpc-gateway/proto/api"
|
||||
pb "github.com/helloworlde/grpc-gateway/proto/api"
|
||||
_ "github.com/mbobakov/grpc-consul-resolver"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
|
@ -49,11 +49,11 @@ func run() error {
|
|||
}
|
||||
defer conn.Close()
|
||||
|
||||
c := helloworld.NewHelloServiceClient(conn)
|
||||
c := pb.NewHelloServiceClient(conn)
|
||||
|
||||
// Contact the server and print out its response.
|
||||
|
||||
r, err := c.Hello(ctx, &helloworld.HelloMessage{
|
||||
r, err := c.Hello(ctx, &pb.HelloMessage{
|
||||
Message: defaultName,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
|||
28
go.mod
28
go.mod
|
|
@ -1,9 +1,8 @@
|
|||
module github.com/helloworlde/grpc-gateway
|
||||
|
||||
go 1.15
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.5.3
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3
|
||||
github.com/hashicorp/consul/api v1.27.0
|
||||
github.com/mbobakov/grpc-consul-resolver v1.5.3
|
||||
|
|
@ -11,3 +10,28 @@ require (
|
|||
google.golang.org/grpc v1.54.0
|
||||
google.golang.org/protobuf v1.30.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/armon/go-metrics v0.4.1 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-playground/form v3.1.4+incompatible // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/hashicorp/serf v0.10.1 // indirect
|
||||
github.com/jpillora/backoff v1.0.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
)
|
||||
|
|
|
|||
4
main.go
4
main.go
|
|
@ -1,8 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/helloworlde/grpc-gateway/server"
|
||||
)
|
||||
import "github.com/helloworlde/grpc-gateway/server"
|
||||
|
||||
func main() {
|
||||
go server.StartGrpcServer()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@ import (
|
|||
)
|
||||
|
||||
type HelloService struct {
|
||||
pb.UnimplementedHelloServiceServer
|
||||
}
|
||||
|
||||
// mustEmbedUnimplementedHelloServiceServer implements grpc_gateway.HelloServiceServer.
|
||||
func (*HelloService) mustEmbedUnimplementedHelloServiceServer() {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (h *HelloService) Hello(ctx context.Context, message *pb.HelloMessage) (*pb.HelloResponse, error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue